I am seeing some very odd behavior in the way that .net sorts strings when using List.Sort.
Here's what I mean. This example conforms with what I believe to be the correct ordering of these special characters lexicographically:
public void sortOrder()
{
var list = new List<string> {"_", "-"};
list.Sort();
Console.WriteLine("Output: " + string.Join(", ", list));
}
And I get -, _
as a result which I believe to be correct. However when I do the following:
public void sortOrder2()
{
var list = new List<string> {"x-amz-meta-file-number", "x-amz-meta-file_type"};
list.Sort();
Console.WriteLine("Output: " + string.Join(", ", list));
}
I get x-amz-meta-file_type, x-amz-meta-file-number
which I'm not expecting based off of my first test.
Anyone have a clue why .net would sort these strings differently?