CompuServe Messages

Alphabetizing Program?

    28-Aug-95 08:47:49
Fm: Jim Butterfield 73624,14
To: COLIN -. GIBSON 102567,1406
>> I need to make a program (in AmigaBasic!) that will sort # of letters and then spew them out … The reference to AmigaBasic indicates that you're working on an older Amiga operating system, but no matter .. Many programmers are anxious to make their sorts FAST, in which case AmigaBasic is likely not the answer. Your best bet for speed would likely be just to put the stuff onto a file and call the CLI/Shell command SORT, which is quite efficient (on your older system, be sure that you have lots of stack or you might crash), sending the output to the screen on whatever… If you really need to do the sorting in AmigaBasic, you have a lot of possible choices to make, a lot of possible methods to use. It's a whole area of study in itself. The main choice looks like this: Simple sort programs: twice the data will take four times as long to sort; Complex sort programs: better, but harder to write. And there are many supplementary questions to be asked. Will the data be almost-sorted? Is there a reason to output data as the sort progresses? (the speed is the same, but that l.o.n.g pause is reduced). Is the data known to fall into a limited number of values (dates, values from 1 to 1000, for example). Will sub-sorts be called for? (first name within sorted last name). The simplest, and some say the least efficient, sort is called the "bubble sort". You go through all adjacent pairs of records; if any pair is out of order, you swap them; in any case, you keep going. Then you repeat the whole procedure until you find no out-of-order pairs, at which time you're sorted. –Jim