Would probably be useful to read up on standard sorting practices, in a general 
algorithms book or a C book.  The algorithm you want to use depends on how sorted the 
unsorted data actually is (your likely choices, and the PalmOS supplied algorithms, 
are quick and insertion sort, where insertion is better if the data is already 
"mostly" sorted).
Make sure to keep the comparisons themselves (the N in all those big-Oh descriptions) 
as fast as possible -- 300 items isn't all that many in terms of the algorithmic 
overhead.  If you can do stuff here to avoid locking and unlocking the same memory 
blocks numerous times, etc., that would help.  Pay close attention to every single 
thing you do in the comparison, once you do enough of them that little difference 
between kinds of string comparisons, for example, starts to make a measurable 
difference.
Bear in mind that sorting is always going to suck, relatively anyway.  If you have a 
lot of items and just can't get it fast enough, you could think of presorting and then 
storing the sort results for later use.  I did something like this once whereby I 
stored an array of the final sort positions of all items along with my item set, the 
array itself ordered by unsorted item number.  That way to figure out the final sorted 
position of an item, whether I had the complete dataset or any subset of it, I just 
had to look in that array position for the final sorted position.  Of course this kind 
of scheme assumes that there is a good time to do the full sort, either before the app 
is deployed or during some user downtime, initialization process, or whatever, and 
will result in some extra data hanging around, not to mention the complexity of 
dealing with less than complete sets.  For what it's worth, though, I implemented a 
"sort" of a dataset of about 40000 items, where I would end up with any subset from 0 
to 40000 items displayed to a user in various orders, and its all basically 
instantaneous from the user perspective.
Good luck,
Will
> Hello All,
> 
> Does anyone have any suggestions as to how to speed up a Database sort?
> I think AddressBook is able to retrieve the data is a quick time. 
> My question concerns DmQuickSort and DmInsertionSort to sort
> the database. Having even a small database of 300 records can take up to
> 3-4 seconds.
> Anything larger is even worse. 
> 
> 
> Regds
> Jeff

-- 
Composed with Newz Crawler 1.5 http://www.newzcrawler.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to