Adam,
The ArrayList.Sort methods supports an IComparer parameter that indicates
how to compare values.
If you do not pass an IComparer value it uses the IComparable of each
element (in other words it asks each string to compare itself to the next
one).
..NET defines two IComparer classes that you would use with ArrayList.Sort
System.Collecti ons.Comparer & System.Collecti ons.CaseInsensi tiveComparer.
Where Comparer does a case sensitive sort, and CaseInsensitive Comparer does
a case insensitive sort.
If you truly want an Ordinal sort I would define my own Comparer
Something like:
Public Class OrdinalComparer
Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As
Integer Implements System.Collecti ons.IComparer.C ompare
Dim s1 As String = DirectCast(x, String)
Dim s2 As String = DirectCast(y, String)
Return String.CompareO rdinal(s1, s2)
End Function
End Class
Private Shared Sub PrintList(ByVal list As ArrayList, ByVal category As
String)
For Each value As String In list
Debug.WriteLine (value, category)
Next
End Sub
Public Shared Sub Main()
Dim list As New ArrayList
list.Add("Abc")
list.Add("abc")
list.Add("_bc")
list.Sort()
PrintList(list, "IComparabl e")
list.Sort(CaseI nsensitiveCompa rer.DefaultInva riant)
PrintList(list, "case insensitive")
list.Sort(Compa rer.DefaultInva riant)
PrintList(list, "case sensitive")
list.Sort(New OrdinalComparer )
PrintList(list, "ordinal")
End Sub
Hope this helps
Jay
"Adam J. Schaff" <as*****@cascoc dev.com> wrote in message
news:uP******** *******@TK2MSFT NGP12.phx.gbl.. .
Sounds like an ordinal sort might be what I want. Can anyone show me how
to force ArrayList.Sort to perform an ordinal sort?