From: | David McMinn |
Date: | 4 Aug 2001 at 12:30:57 |
Subject: | Re: sort and sortlist |
On 4 Aug 01, at 10:24, Steve broke out long enough to write:
> >DA> I thought bubblesort is already fairly quick. iirc There`s a sort
> >DA> source on aminet showing some sort routines. Check that out, it had DA>
> >at least one very fast routine. It shows graphically how fast too.
>
> >DA It's actually a fairly slow sort. Its efficiency drops off extremely DA
> >fast once you get more than a few elements in the list.
>
> And my array has a theoretical maximum of 5000 elements (though I've only
> used about 300 of them personally), and if there's any demand, that could go
> up. (The program is GHelp, a global help system, and the array holds the
> filename of all AmigaGuides on your system - I assume no-one has more than
> 5000 ATM)
Wait a minute. You're using a List, and you've limited the number of items
and you want a fast sort routine? Why don't you use DLL? It's compatible
with the Blitz lists (in terms of list structure), it supports unlimited
items and you get fast sorting routines thrown in for free (I can't
remember the name, but it's the fastest one where you split the list in
half - is that the QuickSort?).
Also if you must write a sort routine yourself, you can get a faster search
than the bubble sort quite easily by only swapping the items once per loop
(i.e. find the smallest, largest and stick them at either end of the list).
The code is quite similar to the bubble sort. And if you do do this, and
you are using strings, grab a copy of the asm string compare routines from
Aminet that I wrote - they're bucketloads faster than doinf "if a$>b$".
[) /\ \/ ][ [) |\/| c |\/| ][ |\| |\| | dave@blitz-2000.co.uk
http://members.nbci.com/david_mcminn | ICQ=16827694
---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie