-1

I would like to create an alphabetic sorter on Vb. I want the user to be able to type things into a textbox and then sort them alphabetically in another label. I am not fully sure how to do this.

1 Answers1

1

The List type has a useful subroutine called Sort that will sort your List either by a default sorting order or with a custom one. Or sort with lambda.

    Module Module1
Sub Main()
    Dim l As List(Of String) = New List(Of String)
    l.Add("mississippi")
    l.Add("indus")
    l.Add("danube")
    l.Add("nile")

    ' Sort using lambda expression.
    l.Sort(Function(elementA As String, elementB As String)
               Return elementA.Length.CompareTo(elementB.Length)
           End Function)

    For Each element As String In l
        Console.WriteLine(element)
    Next
End Sub

End Module

In Detail - Lamda for multicolumn list sort example

Prof.
  • 11
  • 2