TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
Jesse Farmer <[log in to unmask]>
Reply To:
Jesse Farmer <[log in to unmask]>
Date:
Sat, 16 Dec 2000 22:59:18 -0500
Content-Type:
text/plain
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:

A2
A3
A1
A4
B1
B3
B2

And I need to sort it so it looks like:

A1
A2
A3
A4
B1
B2
B3

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

ATOM RSS1 RSS2