Well, ignoring the dashes is fairly innocent. If you want to include them, perhaps use StringComparison.Ordinal
in the overload.
Reading the docs for string.Compare
, it uses word sort rules, which from here means :
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.
At least it is transitive: I logged a bug with "connect" about something very similar involving dashes - where A < B, B < C and C < A. since a non-transitive comparison essentially breaks the rules of sorting. It was closed "will not fix". Here it is:
string s1 = "-0.67:-0.33:0.33";
string s2 = "0.67:-0.33:0.33";
string s3 = "-0.67:0.33:-0.33";
Console.WriteLine(s1.CompareTo(s2));
Console.WriteLine(s2.CompareTo(s3));
Console.WriteLine(s1.CompareTo(s3));
(returns 1,1,-1 on my machine)