'
' BubbleSort - sort an array
'
' Author: Joe Strazzere
'
Dim TheArray(5)
TheArray(0)=Random(99999)
TheArray(1)=Random(99999)
TheArray(2)=Random(99999)
TheArray(3)=Random(99999)
TheArray(4)=Random(99999)
IsNotSorted = 0
IsSorted = 1
LastElementInArray = 4
SortedFlag = IsNotSorted
While SortedFlag = IsNotSorted
SortedFlag = IsSorted
Index = 0
While Index < LastElementInArray
If TheArray(Index) > TheArray(Index + 1) Then
Temp = TheArray(Index + 1)
TheArray(Index + 1) = TheArray(Index)
TheArray(Index) = Temp
SortedFlag = IsNotSorted
End If
Index = Index+1
Wend
Wend
MsgBox(Str$(TheArray(0))+CRLF+Str$(TheArray(1))+CRLF+Str$(TheArray(2))+CRLF+Str$(TheArray(3))+CRLF+Str$(TheArray(4)))