W
william.hooper
There is a longer article about this subject here:
http://www.codeproject.com/useritems/SortedList_Bug.asp
See the main article and the reply thread started by Robert Rohde.
Alternatively look at this code:
ArrayList a=new ArrayList();
string s1 = "-0.67:-0.33:0.33";
string s2 = "0.67:-0.33:0.33";
string s3 = "-0.67:0.33:-0.33";
a.Add(s1);
a.Add(s2);
a.Add(s3);
a.Sort();
for (int i=0; i<3; i++) Console.WriteLine( a );
Console.WriteLine();
a.Clear();
a.Add(s1);
a.Add(s3);
a.Add(s2);
a.Sort();
for (int i=0; i<3; i++) Console.WriteLine( a );
This code produces the following six lines of output:
-0.67:0.33:-0.33
0.67:-0.33:0.33
-0.67:-0.33:0.33
-0.67:-0.33:0.33
-0.67:0.33:-0.33
0.67:-0.33:0.33
Note that the .Sort produces different outputs depending on the order
the strings are added.
It looks like the Sort algorithm is ignoring the "-" mark.
This is a very serious Bug impacting the System.Collections Array,
SortedList etc.
http://www.codeproject.com/useritems/SortedList_Bug.asp
See the main article and the reply thread started by Robert Rohde.
Alternatively look at this code:
ArrayList a=new ArrayList();
string s1 = "-0.67:-0.33:0.33";
string s2 = "0.67:-0.33:0.33";
string s3 = "-0.67:0.33:-0.33";
a.Add(s1);
a.Add(s2);
a.Add(s3);
a.Sort();
for (int i=0; i<3; i++) Console.WriteLine( a );
Console.WriteLine();
a.Clear();
a.Add(s1);
a.Add(s3);
a.Add(s2);
a.Sort();
for (int i=0; i<3; i++) Console.WriteLine( a );
This code produces the following six lines of output:
-0.67:0.33:-0.33
0.67:-0.33:0.33
-0.67:-0.33:0.33
-0.67:-0.33:0.33
-0.67:0.33:-0.33
0.67:-0.33:0.33
Note that the .Sort produces different outputs depending on the order
the strings are added.
It looks like the Sort algorithm is ignoring the "-" mark.
This is a very serious Bug impacting the System.Collections Array,
SortedList etc.