TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mime-Version: 1.0
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
From: Jesse Farmer <[log in to unmask]>
Date: Sat, 16 Dec 2000 22:59:18 -0500
Content-Type: text/plain; charset="us-ascii"; format=flowed
Reply-To: Jesse Farmer <[log in to unmask]>
Parts/Attachments: text/plain (49 lines)
Hi everyone.

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.

-Jesse Farmer