Func_ra_sort: TSL's Missing Array Sorting Functions


I don"t know how useful this module is going to be compared to the other modules that I"ve posted here, but it"s a pretty interesting project for me.

The first time I started working on this module was in the Summer of 1999. I needed to sort a large array (and the plain and simple bubblesort as usual was dragging along). I knew the other sorting algorithms (heap, merge, quick) but couldn't remember of their implementation so I went through my old C programming book and found explanation of their implementation. The simplest one to implement in WinRunner was quicksort, so I created that one and did away with it. The next year (November 2000), I stumbled upon this old module browsing through my old tests and decided to complete it. I added the mergesort implementation, and spent several days tweaking the other sorting algorithms to see how fast they would run. Not bad.

So here we are, three sorting functions ready to use. Remember that this module requires the func_ra module, so be sure to load that module first before using this module.

Summary of the features:

Sort an array using bubblesort -- very simple (array must start at index 0). This sorting method is very inefficient for large arrays. Seriously consider using array_mergesort() or array_quicksort() instead.
Another implementation of array_bubblesort that allows for sorting only on a subset of an array.
Sort a sequentially ordered array using mergesort algorithm (array must start at index 0).
Sort a subset of a sequentially ordered array using mergesort algorithm.
Sort a sequentially ordered array using quicksort algorithm.
Sort a subset or a sequentially ordered array using quicksort algorithm.

Generally, if the array to be sorted has a starting index of 0, using the default sorting functions (array_bubblesort, array_mergesort, array_quicksort) are faster than the subset version (array_bubblesort2, array_mergesort2, array_quicksort2). However, the subset version are more flexible (though internally they use the default functions also).

You can download the func_ra_sort module (and the supporting func_ra module) here:

Tech Page @