Monday, June 25, 2007

Sorting a Portion of a Collection

int[] arNumbers = {13, 4, 7, 10, 2, 8, 17, 5, 1, 11};
System.Array.Sort(arNumbers, 2, 5); // sort numbers between 2 to 5

Automatic Sorting Using a SortedList

Dim usStates As New SortedList
usStates.Add("CA", "California")
usStates.Add("AZ", "Arizona")
usStates.Add("NV", "Nevada")
Console.WriteLine(usStates.GetKey(1) + usStates.GetByIndex(1))Console.ReadLine()
' slsStates order:'
' Keys Values
' ---------------
' AZ Arizona
' CA California
' NV Nevada

No comments: