Notepad++ Sort Class
-
Hi,
When I use “Edit > Line Operations > Sort Lines Lex. Ascending Ignoring Case” I get a different sort order than when I use PowerShell’s “Sort-Object” command.
I have a process where we compare a list from one source with a list from another source.
What class does Notepad++ use to implement the “Sort Lines Lex. Ascending Ignoring Case” feature?
Maybe I can use that class in PowerShell to sort there and get the same results. -
@JediSQL
I don’t know what you mean by “class”, but Notepad++ only ignores the case of ASCII characters, (e.g., treatsA
anda
as equivalent but notỒ
andồ
(to choose two random non-ASCII letters)). Most popular case-insensitive string-sorting algorithms (including presumably PowerShell’s) ignore the case of all letters, including non-ASCII ones.There is already an open issue in the GitHub repo. I started working on a pull request for this issue, but I got side-tracked. I’ll try to poke the core devs again and see if I get get it moving again.
-
@Mark-Olson Thank you. My problem is not with foreign characters. Notepad++ sorts letters before underscores; PowerShell sorts letters after underscores. The two would sort these in opposite orders:
abc, ab_ -
@Mark-Olson Oh, by “class,” I assume that Notepad++ is using some .Net framework class to do the sorting.
-
@JediSQL said in Notepad++ Sort Class:
What class does Notepad++ use to implement the “Sort Lines Lex. Ascending Ignoring Case” feature?
It works its way down to this line:
LONG lres = LCMapString(LOCALE_INVARIANT, LCMAP_UPPERCASE, &input, 1, &result, 1);
to convert all strings to be compared to uppercase. -
You might be able to use the Sort Ascending (Locale) function in my Columns++ plugin. I think this is the same sort Windows uses for filenames, so it might also be the same sort you’re getting from PowerShell.
-
@Coises Thank you. I do not think that addresses, though, the relative order of letters versus special characters. (this is a reply to your first post.)
-
@Coises Hmm, OK. I’ll take a look at Columns++.
-
@JediSQL said in Notepad++ Sort Class:
I do not think that addresses, though, the relative order of letters versus special characters.
Yes it does. Uppercase come before underscore come before lowercase in lexicographic order. If Notepad++ is capitalizing all letters to sort ignoring case, then it will put letters before underscore. If PowerShell is lowercasing all letters, it will put letters after underscore.