The
Array.Sort(Of TKey, TValue) Method (TKey(), TValue(), IComparer(Of TKey))
explained here
http://msdn.microsoft.com/en-us/library/x8kwfbye.aspx[
^] can be used for this purpose. In the present case, as the sorting is to be done in
Descending
order IComparer is required, which is explained here
http://msdn.microsoft.com/en-us/library/8ehhxeaf.aspx#Y700[
^]
is required
Private Sub Main()
Dim Array1(4) As Double
Dim Array2(4) As Double
Array1(0) = 2.3
Array1(1) = 4.2
Array1(2) = 1.9
Array1(3) = 0.2
Array1(4) = 0.88
Array2(0) = 0.19
Array2(1) = 0.002
Array2(2) = 0.2
Array2(3) = 0.45
Array2(4) = 1.8
Array.Sort(Of Double, Double)(Array1, Array2, New ItemComparer())
End Sub
Public Class ItemComparer
Implements IComparer(Of Double)
Public Function Compare(x As Double, y As Double) As Integer _
Implements IComparer(Of Double).Compare
Return y.CompareTo(x)
End Function
End Class