Friday, February 17, 2012
Array sorting procedure
'------------------------------------------------------------------------
Private Sub SortArray(arr() As Integer)
'------------------------------------------------------------------------
'This sub uses the Bubble Sort algorithm to sort an array of integers.
Dim lngX As Long
Dim lngY As Long
Dim tmp As Integer
For lngX = LBound(arr) To (UBound(arr) - 1)
For lngY = LBound(arr) To (UBound(arr) - 1)
If arr(lngY) > arr(lngY + 1) Then
'exchange the items
tmp = arr(lngY)
arr(lngY) = arr(lngY + 1)
arr(lngY + 1) = tmp
End If
Next lngY
Next lngX
End Sub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment