Sorts the elements in a range in ArrayList using the specified comparer.
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("T") myAL.Add("Q") myAL.Add("B") myAL.Add("F") myAL.Add("j") myAL.Add("o") myAL.Add("t") myAL.Add("a") myAL.Add("d") PrintIndexAndValues(myAL) myAL.Sort(1, 3, Nothing) PrintIndexAndValues(myAL) Dim myComparer = New myReverserClass() myAL.Sort(1, 3, myComparer) PrintIndexAndValues(myAL) End Sub Public Shared Sub PrintIndexAndValues(myList As IEnumerable) Dim i As Integer = 0 Dim obj As [Object] For Each obj In myList Console.WriteLine(vbTab + "[{0}]:" + vbTab + "{1}", i, obj) i = i + 1 Next obj Console.WriteLine() End Sub End Class