As per MSDN Docs String.Compare:
Notes to Callers: Character sets include ignorable characters. The
Compare(String, Int32, String, Int32, Int32, CultureInfo, CompareOptions)
method does not consider these characters when it performs a
linguistic or culture-sensitive comparison. To recognize ignorable
characters in your comparison, supply a value of
CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for the
options parameter.
If you add StringComparer.Ordinal
it will work as expected.
var sorted = new[] { "-1.0", "0.0", "1.0", "1.1", "2.0" }
.OrderBy(s => s, StringComparer.Ordinal)
.ToArray();
Console.WriteLine(string.Join(", ", sorted));
So as you can see the -
will be completely ignored, meaning that "-1.0"
and "1.0"
are the same
Also as per MSDN CompareOptions Enumeration Remakrs
The .NET Framework uses three distinct ways of sorting: word sort,
string sort, and ordinal sort. Word sort performs a culture-sensitive
comparison of strings. Certain nonalphanumeric characters might have
special weights assigned to them. For example, the hyphen ("-") might
have a very small weight assigned to it so that "coop" and "co-op"
appear next to each other in a sorted list. String sort is similar to
word sort, except that there are no special cases. Therefore, all
nonalphanumeric symbols come before all alphanumeric characters.
Ordinal sort compares strings based on the Unicode values of each
element of the string.