Sorts the entire Array pair using the default comparer
Imports System
Imports System.Collections
Public Class SamplesArray
Public Class myReverserClass
Implements IComparer
Function Compare(x As [Object], y As [Object]) As Integer _
Implements IComparer.Compare
Return New CaseInsensitiveComparer().Compare(y, x)
End Function
End Class
Public Shared Sub Main()
Dim myKeys As [String]() = {"red", "green", "yellow"}
Dim myValues As [String]() = {"RED", "GREEN", "YELLOW"}
Dim myComparer = New myReverserClass()
PrintKeysAndValues(myKeys, myValues)
Array.Sort(myKeys, myValues)
Console.WriteLine("After sorting the entire Array using the default comparer:")
PrintKeysAndValues(myKeys, myValues)
End Sub
Public Shared Sub PrintKeysAndValues(myKeys() As [String], myValues() As [String])
Dim i As Integer
For i = 0 To myKeys.Length - 1
Console.WriteLine(" {0,-10}: {1}", myKeys(i), myValues(i))
Next i
End Sub
End Class
Related examples in the same category