Quick Sort VBA
Access VBA Recursive Quick Sort Program:
At times you may need to sort a list of values programmatically. One of the most efficient and easiest sorts is the recursive quick sort. Recursive means that the routine calls itself.
The concept used in the quick sort is as follows:
Choose the middle value of the list.
Starting at the bottom of the list move up the list, toward the middle, until you find the first value that is not in sort order in relation to the middle value.
Starting at the top of the list move down the list, toward the middle, until you find the first value that is not in sort order in relation to the middle value.
Now switch the two values that were found out of sort order.
Repeat steps 2 through five until you get to the middle of the list.
Call the sort routine on the top half of the list.
Call the sort routine on the bottom half of the list.
What happens is that each pass through the routine does a small amount of sorting then cuts the size of the list in half and sends the 2 new halves to be sorted. This continues until each part of the list is perfectly sorted. The result is that the overall whole is sorted.
Private Sub QuickSort(strArray() As String, intBottom As Integer, intTop As Integer)
Dim strPivot As String, strTemp As String
Dim intBottomTemp As Integer, intTopTemp As Integer
intBottomTemp = intBottom
intTopTemp = intTop
strPivot = strArray((intBottom + intTop) 2)