A
Adam J. Schaff
Hello. I recently noticed that the Sort method of the .NET ArrayList class
does not behave as I expected. I expect 'A' < '_' < 'a' (as per their ascii
values) but what I got was the opposite. Simple code:
Dim y As New ArrayList
y.Add("Abc")
y.Add("abc")
y.Add("_bc")
y.Sort()
Examine y and you'll see that 'Abc' is last rather than first. So I'm
guessing from this that the default behavior is to do a case-insensitive
sort. Does anyone know how I can get it to do a case-sensitive sort?
Ironically, I found a CaseInsensitiveComparer class, but no
CaseSensitiveComparer class, so I'm not sure whether the IComparer overload
of the Sort method would somehow be helpful.
Any help would be much appereciated.
-AJ
does not behave as I expected. I expect 'A' < '_' < 'a' (as per their ascii
values) but what I got was the opposite. Simple code:
Dim y As New ArrayList
y.Add("Abc")
y.Add("abc")
y.Add("_bc")
y.Sort()
Examine y and you'll see that 'Abc' is last rather than first. So I'm
guessing from this that the default behavior is to do a case-insensitive
sort. Does anyone know how I can get it to do a case-sensitive sort?
Ironically, I found a CaseInsensitiveComparer class, but no
CaseSensitiveComparer class, so I'm not sure whether the IComparer overload
of the Sort method would somehow be helpful.
Any help would be much appereciated.
-AJ