Sorting List Items Using VB.NET
In this article I explained, how to sort list items in VB.NET.
Sorting
The Sort method sorts all the items of a List. The following code snippet creates and sorts a List.
Imports System.Text
Imports System.IO
Imports System.Collections.Generic
Module Module1
Sub Main()
Dim DepartmentList As New List(Of String)()
DepartmentList.Add("Service")
DepartmentList.Add("Finance")
DepartmentList.Add("Maintenance")
DepartmentList.Add("Testing")
DepartmentList.Add("HR")
' Read all data
Console.WriteLine("Original Department List")
For Each department In DepartmentList
Console.WriteLine(department)
Next
DepartmentList.Sort()
Console.WriteLine()
Console.WriteLine()
Console.WriteLine("Sorted Department List is :")
For Each department In DepartmentList
Console.WriteLine(department)
Next
Console.ReadLine()
End Sub
End Module
Output:
