Sorry I posted this on another news group and
microsoft.public.dotnet.languages.csharp and it has had good response
there.
The problem is the comparer:
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( String.Compare(s1,s2));
Console.WriteLine( String.Compare(s2,s3));
Console.WriteLine( String.Compare(s3,s1));
Console.WriteLine();
Console.WriteLine( String.CompareOrdinal(s1, s2));
Console.WriteLine( String.CompareOrdinal(s2, s3));
Console.WriteLine( String.CompareOrdinal(s3, s1));
returns:
1
1
1
-3
3
3
So the String.Compare is giving crazy results with this example.
It is not ignoring the hyphens - which would return 0,0,0 but instead
1,1,1. The String.Compare function works OK if you have one hypen in a
string, but it can get confused if there are two hyphens in the text.
Using String.CompareOrdinal fixes the problem but the String.Compare
looks buggy, and if not this example should at least be posted in the
documentation.