Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesArrayList
Public Class myReverserClass
Implements IComparer
Public Function Compare( ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
Return New CaseInsensitiveComparer().Compare(y, x)
End Function
End Class
Public Shared Sub Main()
Dim myAL As New ArrayList()
myAL.Add("The")
myAL.Add("quick")
myAL.Add("brown")
myAL.Add("fox")
myAL.Add("jumps")
myAL.Add("over")
myAL.Add("the")
myAL.Add("lazy")
myAL.Add("dog")
PrintIndexAndValues(myAL)
myAL.Sort()
PrintIndexAndValues(myAL)
Dim myComparer = New myReverserClass()
myAL.Sort(myComparer)
PrintIndexAndValues(myAL)
End Sub 'Main
Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
Dim i As Integer = 0
Dim obj As [Object]
For Each obj In myList
Console.WriteLine("[{0}]:" + vbTab + "{1}", i, obj)
i = i + 1
Next obj
Console.WriteLine()
End Sub
End Class