'Visual Basic 2010 Sorteren van Arrays - Selection Sort Arrays Module SelectionSortExample Sub Main() Dim count As Integer = 5 Dim upperbound As Integer = count - 1 Dim numbers(upperbound) As Integer ' Dim index As Integer For index = 0 To upperbound numbers(index) = (count ^ index) * 93 Mod 97 - (count \ (index + 1)) Next ' Console.Write("unsorted array : ") For index = 0 To upperbound Console.Write(numbers(index) & " ") Next Console.WriteLine() ' Dim unsortedCount As Integer = count Do While unsortedCount > 1 Dim startIndexUnsortedPart As Integer = count - unsortedCount ' Dim indexSmallestElement As Integer = startIndexUnsortedPart For index = startIndexUnsortedPart To upperbound If numbers(index) < numbers(indexSmallestElement) Then indexSmallestElement = index End If Next ' Dim backup As Integer = numbers(indexSmallestElement) numbers(indexSmallestElement) = numbers(startIndexUnsortedPart) numbers(startIndexUnsortedPart) = backup ' unsortedCount -= 1 ' Console.Write("temporary array : ") For index = 0 To upperbound Console.Write(numbers(index) & " ") Next Console.WriteLine() Loop ' Console.Write("sorted array : ") For index = 0 To upperbound Console.Write(numbers(index) & " ") Next ' Console.ReadLine() End Sub End Module 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.