My data structures textbook and Mike Feldman's both contain a wide variety
of generic sorting procedures that do exactly what you desire.
Ada Plus Data Structures: An Object Based Approach
Dale, Lilly, McCormick
Jones and Bartlett Publisher
At 10:59 PM 12/16/2000 -0500, Jesse Farmer wrote:
>Maybe I just haven't looked hard enough, but in the few hours that I
>searched, I've been unable to find a good package of sorting
>routines. Does anyone know of such a package?
>Here is what I need to do: sort an array of a objects of a user defined
>type. Sort of an example of what I need to do is like this: I have an
>array as follows:
>And I need to sort it so it looks like:
>Note that each object really has the letter and number as seperate fields
>(ie. Object1.Letter Object1.Number ). Above are likely values for each
>object that I would encounter.
>Note that the A's and B's will all ready be in order (ie all A's before all
>B's) as a given, so I don't need to worry about that part. What I am
>wondering however, is what might be the best sorting algorithm to do
>this. Quite likely, the number of objects at a given time will be less
>than 20, which makes me wonder whether or not using QuickSort would be the
>best way to go. Overhead is a concern, but speed is definitely the main
>priority. One of the thing I wonder about, is should I have my program
>sort the whole array in one step, or have my code step thru each Letter
>Prefix. If I have it go thru and just do a Letter worth at a time, it will
>almost certainly always be under 20 things to sort per letter. Because of
>the small number of objects I would be sorting in this case, I'm also
>considering shell sort, or insertion sort.
>I'd be very interested in knowing what anyone thinks, and where I might
>find a very fast implementation of QuickSort at. Thanks.