Sveučilište u Zagrebu  |  Filozofski fakultet  |  Služba za informatiku  |  links

 

System.Comparison(Of T) Sample

 

Module Module1

    Sub Main()

        Dim myList As New List(Of String) From {"pero", "gjuro", "miro", "vinko", "janko", "tonko", "hinko"}

        myList.Sort(Function(a, b) b.CompareTo(a))  ' reverse alpha sort

        Console.WriteLine("REVERSE ORDER")
        For Each s In myList
            Console.WriteLine(s)
        Next

        myList.Sort(AddressOf RegularAlphaSort)  ' regular alpha sort, alternative way of doing sort

        Console.WriteLine("REGULAR ORDER")
        For Each s In myList
            Console.WriteLine(s)
        Next

    End Sub

    Function RegularAlphaSort(s1 As String, s2 As String) As Integer

        Return s1.CompareTo(s2)

    End Function

End Module

komentare molim ovdje