You can use a Bubble sort. Which allows you to run through a list of values and float the largest ones to the top of the list and the smallest ones to the bottom (or vice versa).
Try using the following module:
Now simply call the procedure and pass the array you want sorted, because arrays are passed by reference the array will be sorted when it returns.Code:Private Sub BubbleSort(asValues() As String) Dim iLimit As Integer Dim iStep As Integer Dim iCompare As Integer Dim sTemp As String iLimit = UBound(asValues) - 1 For iStep = 0 To iLimit Step 1 For iCompare = 0 To iLimit Step 1 If StrComp(asValues(iCompare), asValues(iCompare + 1)) > 0 Then sTemp = asValues(iCompare) asValues(iCompare) = asValues(iCompare + 1) asValues(iCompare + 1) = sTemp End If Next iCompare Next iStep End Sub
Hope this helps.




Reply With Quote