Consider this code
var strings2 = new List
{
\"0\", // Ascii code 48 (decimal)
\"|\" // Ascii code 125 (decimal)
};
va
Here you go:
The comparison uses the current culture to obtain culture-specific information such as casing rules and the alphabetic order of individual characters. For example, a culture could specify that certain combinations of characters be treated as a single character, or uppercase and lowercase characters be compared in a particular way, or that the sorting order of a character depends on the characters that precede or follow it.
Source: String.Compare Method on MSDN
The ".OrderBy" function utilizes the default comparer for a string. That comparer is not necessarily going to return a sort order based on the ASCII code.
For a list of all the different string comparers, see the article on MSDN.
The order depends on the culture that you use.
You can pass the culture in an overload to OrderBy.
var sorted = strings2.OrderBy(x => x, StringComparer.InvariantCulture)