Board index » delphi » Fast sorting of strings....

Fast sorting of strings....


I'm trying to write a program to sort an array of records given two sort

Something along the lines of :

    TInfo = record
        field1 : string;
        field2 : string;
        field3 : string;
        field4 : string;

   TArrayOfInfo = array[1..maxarray] of TInfo;

I'd like a fast sort, such as a quicksort, that I could use and sort by say,
field1 then secondary sort by field2.
Is there any easy way of doing this, because if there isn't I'm going to
have a nightmare of a time.

Thanks to anyone who comes up with anything,

Martin Platt.


Re:Fast sorting of strings....


The easiest way I can think of to do this is to read your record array into a
TList and then call Sort on it. Your parameter to Sort (a function of type
TListSortCompare) would contain the appropriate sort criteria.
Look at classes.pas. Come back if you nedd assistance.

Charles Johnson

Re:Fast sorting of strings....

Go to the Delphi Super Page and search for anything made by Martin
Waldenburg or Martin Harvey (sorry guys, I can never remember who made
what). You'll find a LOT of searching and sorting algoritmes, which are
incredibly fast.



Niels Vanspauwen      
Student @ KULeuven
Faculty of Civil Engineering
Department of Computer Science

E-Mail: Niels.Vanspauwen!
(Remove !NSPM! from E-mail address if you want to reply...)

Other Threads