Simple Bubblesort routine:   Return to List

' If the number of elements being sorted exceed 30 (or speed is what you're after -- and who isn't?!) -- use a QuickSort.  The term "Quick" means what it says.

Do
    AnyChanges = False
    For i = 1 To UBound(myArray()) - 1
         If myArray(i) > myArray(i + 1) Then

             ' These two need to be swapped
             SwapFH = myArray(i)
             myArray(i) = myArray(i + 1)
             myArray(i + 1) = SwapFH
             AnyChanges = True
         End If
    Next i Loop Until Not AnyChanges

See also:
Array Converted to Delimited Text String
Building an Array of Filenames (after browse)
Delimited Text to an Array (similar to Split())
Determining Upper & Lower Array Bounds
Erasing an Array (removing all the elements)
Feed an Array into a New Document (del dupes)
Filename Array from Active Directory
QuickSort routine
QuickSort (Fast!!) (Multidimensional on 2 dims)
QuickSort (Fast!!) (Multidimensional on 3 dims)
QuickSort (Fast!!) (Single Dimension)
Removing Duplicates from an Array
SQL Query Results placed in an Array
Using Split() function to create Array



Note to Webmaster