The SortedList Collection

The System.Collections.SortedList collection works like HashTable but differs in that items can be accessed via the key or the index items are automatically sorted based on the key. For example, look at the following code:

Dim sl As New SortedListsl.Add("Del Sole", 2)sl.Add("Alessandro", 1)For Each item As String In sl.Keys    Console.WriteLine(item)Next

It sorts items based on the key; therefore, it produces the following result:

AlessandroDel Sole

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.