Sub SortArray(array)
n = Ubound(Array) + 1
For X = 1 To (n - 1) 'Perform the following loop for each value in the arrays
J = X
Do While J >= 1
If Array(J) < Array(J - 1) Then ' Compares two values in the array
ValueA = Array(J) ' Swap the values compared since the second is less than the first
ValueB = Array(J - 1)
Array(J) = ValueB
Array(J - 1) = ValueA
J = J - 1 ' Increment to the next two down in the array (descending to index 0 )
Else
Exit Do ' Index 0 reached, goto next X index in the array and loop again
End If
Loop
Next
End Sub