Array.Sort<(Of <(TKey, TValue>)>)(array[]()[], array[]()[]),
Imports System
Imports System.Collections.Generic
Public Class ReverseComparer
Implements IComparer(Of String)
Public Function Compare(ByVal x As String,ByVal y As String) As Integer Implements IComparer(Of String).Compare
Return y.CompareTo(x)
End Function
End Class
Public Class Example
Public Shared Sub Main()
Dim letters() As String = {"A", "B", "E", "C", "F", "G" }
Dim letterSizes() As Integer = { 40, 5, 3, 22, 1, 18 }
Console.WriteLine()
For i As Integer = 0 To letters.Length - 1
Console.WriteLine("{0}: up to {1} meters long.",letters(i), letterSizes(i))
Next
Console.WriteLine("Sort(letters, letterSizes)")
Array.Sort(letters, letterSizes)
For i As Integer = 0 To letters.Length - 1
Console.WriteLine("{0}: up to {1} meters long.",letters(i), letterSizes(i))
Next
End Sub
End Class
Related examples in the same category