A simple VBScript implementation of QuickSort.
From time to time the need arises to sort a small to medium sized array of text or even numbers in VBScript. This might be in a web page on the client side, in an ASP page, or even in a stand-alone desktop Windows Script File (.WSF).
If your needs are modest and the list of data is short there is no need to search out an array-sort component and deal with ActiveX download warnings and such.
The array size must be reasonable to avoid stack-overflows, since this algorithm is coded using extensive recursion - a hallmark of QuickSort. I can't take the credit, the logic was taken straight from an old Microsoft DOS Basic example. A little tweaking and enhancement and voila!
For most purposes you'll want to rework quicksort.vbs a bit. For example a version that sorts a 2-dimensional array using one column as the sort key would be more practical than this bare-bones sort routine.
Download it here and start expanding on it.
December 2001