ClassSystem.Array SyntaxArray.Sort(array[, comparer]) Array.Sort(array, index, length[, comparer]) Array.Sort(keys, items[, comparer]) Array.Sort(keys, items, index, length[, comparer])
DescriptionThe Sort method sorts a portion of, or all of, an entire one-dimensional array, with an optionally specified key array and an optionally specified IComparer interface. ExamplePublic Sub SortArray( ) ' ----- Start with the unsorted data. Dim counter As Integer Dim dataSet( ) As Integer = {9, 8, 12, 4, 5} For counter = 0 To 4 Console.Write(CStr(dataSet(counter)) & " ") Next counter Console.WriteLine("") ' ----- Sort and display the data. System.Array.Sort(dataSet) Console.WriteLine("Sorted:") For counter = 0 To 4 Console.Write(CStr(dataSet(counter)) & " ") Next counter Console.WriteLine("") End Sub The output is: 9 8 12 4 5 Sorted: 4 5 8 9 12 See AlsoArray Class, Array.Reverse Method |