The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

# Sorting Arrays

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Sorting an array is an iterative process that requires a fairly sophisticated algorithm. An example of a common sorting algorithm, the QuickSort algorithm. The QuickSort algorithm is explained in thorough detail in the Visual Basic Language Developer's Handbook by Ken Getz and Mike Gilbert (Sybex, 2000) — a good place to start if you're looking for more information about sorting arrays.

In brief, the QuickSort algorithm works by using a divide-and-sort strategy. It first finds the middle element in the array, then works its way from the rightmost element to the middle, and from the leftmost element to the middle, comparing elements on both sides of the middle value and swapping their values if necessary. When this part of the sort is complete, the values on the right side are all greater than those on the left, but they're not necessarily in order. The procedure then looks at the values on the left side by using the same strategy — finding a middle value and swapping elements on both sides. It does this until all the elements on the left side have been sorted, and then it tackles the right side. The procedure calls itself recursively and continues executing until the entire array has been sorted.