I want to sort the lines case-sensitive: so if you start with capital “C” then it should be “bigger” (for example) than the one that starts with “c”, but also less than the one that starts with "d".
For example, a sorted list: "a", "A", "chi", "Che", "Chr"
It is written that string comparison methods are case sensitive by default. But it looks like my understanding of "case sensitive" is different from the standard.
None of the default methods that I tried ( String.CompareTo, String.Compare(with different values StringComparison)) gives the result I want.
Here is the code I used for testing:
using System;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
var list = new List<String> { "Che", "Chr", "chi", "a", "A" };
list.Sort((s1, s2) => s1.CompareTo(s2));
for (var i = 0; i < list.Count; i++)
{
Console.WriteLine(list[i]);
}
}
}
: "a" "A" "Che" "chi" "Chr". , "c" "C" s.
, : , ( ) , ? - ?