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.Collections.Comparer & System.Collections.CaseInsensitiveComparer.
Where Comparer does a case sensitive sort, and CaseInsensitiveComparer 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.Collections.IComparer.Compare
Dim s1 As String = DirectCast(x, String)
Dim s2 As String = DirectCast(y, String)
Return String.CompareOrdinal(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, "IComparable")
list.Sort(CaseInsensitiveComparer.DefaultInvariant )
PrintList(list, "case insensitive")
list.Sort(Comparer.DefaultInvariant)
PrintList(list, "case sensitive")
list.Sort(New OrdinalComparer)
PrintList(list, "ordinal")
End Sub
Hope this helps
Jay
"Adam J. Schaff" <as*****@cascocdev.com> wrote in message
news:uP***************@TK2MSFTNGP12.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?