Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Sorts the entire Array 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 myArr As [String]() =  {"The", "QUICK", "BROWN", "FOX", "jumps", "over", "the", "lazy", "dog"}       Dim myComparer = New myReverserClass()       PrintIndexAndValues(myArr)       Array.Sort(myArr)       Console.WriteLine("After sorting the entire Array using the default comparer:")       PrintIndexAndValues(myArr)    End Sub 'Main    Public Shared Sub PrintIndexAndValues(myArr() As [String])       Dim i As Integer       For i = 0 To myArr.Length - 1          Console.WriteLine("   [{0}] : {1}", i, myArr(i))       Next i    End Sub End Class