The motivation for building this library is speed with special emphasis on arrays of C numeric types. The usort libraries use a combination of strategies including bucket sort, radix sort, quicksort, and insertion sort. The speedups will vary depending on: size of the numeric type, size of the array, and computing hardware on which the test is conducted.
This directory contains a set of C language sorting functions. There are two primary subdirectories to look at:
usort - contains optimized sorting routines for each of the basic c numeric types. The "u" is for universal... where the universe refers to the set of basic c numeric types.
qsort - a general purpose quicksort routine.
To use the code, simply #include the appropriate function.
The quicksort library uses static definition of the comparison operator (by means of macros) in order to prevent dispatch overhead. It is intended for general use in addition to its inclusion within the usort stragegies.
For the usorts, the speedups range from 3x for 8 byte numbers to incredable 250x for 1 byte integers (which can be sorted using bucket sort).
I test this code on both 32 and 64 bit intel architectures. Below are complete comparisons of the usorts against the GNU lib C qsort straw man. Timings were on my TravelMate 8210, a 32 bit intel machine with Intel(R) Core2 T7200 @ 2.00GHz and 2 gigs of RAM..