I have a list of UTF-8 strings that I want to sort using Enumerable.OrderBy . Strings can contain any number of character sets, for example, in English, German and Japanese, or a combination of both.
For example, here is an example input list:
["東京","North 東京", "München", "New York", "Chicago", "大阪市"]
I am confused by the fact that using StringComparer.CurrentCulture is the correct string comparison parameter to go to OrderBy(). What if the current application culture en-US, but I still want to correctly sort the UTF-8 data outside of the sort rules en-US?
My confusion is probably due to my understanding of the NLSSORT function in Oracle, which doesn’t quite coincide with comparing .NET strings and sorting semantics. For example, setting NLS_SORT = Japanese_M means that it sorts Latin, West European, and Japanese correctly, regardless of whether any or all characters in a given row are found in the sorted column.
source
share