So the idea is to sort a large STRUCTURE using an element of that structure, for arguments sake Zip Code.
To keep it simple lets pretend that there are two arrays, one integer containing the zip codes and two, a larger structure (3k Bytes) array.
Sorting the integer array is suitably fast with Quick Sort, but tagging the Structure array could be done a little better than simply swapping elements when the integer array swaps elements.
In testing a random 3000 element integer array required 12000 swaps to achieve a completed sort. Swapping the entire structure that many times would have a performance penalty esp if there are many elements.
Ideally I would just sort an array of pointers, but in this case I actually have to return a sorted structure array not an array of sorted pointers. If nothing else this is an exercise in sorting a tagged array.
One approach would be to tag a secondary integer array, and then use the order within it to shuffle the elements of the structure around, thus moving each element only once.
I am not finding much help on the web http://rosettacode.org/wiki/Sorting_an_Array_of_Integers#C
Suggestions for an elegant design would be appreciated.