[comp.lang.pascal] SORT method needed

C0361@univscvm.csd.scarolina.edu ( Thomas Jenkins) (11/02/90)

Hello,

  I'm working on a sort unit.  I need a GOOD sort routine that is fast in
Turbo Pascal.  Once completed, I intend this Sort to be like the IBM BIGSORT.
The user will request file to be sorted with a parameter list like:

  START  LENGTH

    2      4     future :  sort on four keys, sort index length = 31 BYTEs +
    6      2                 4 BYTEs for binary pointer = 35 BYTEs
    120    10    now    :  sort on four keys, sort index length = 265 BYTEs +
    10     15                4 BYTEs for binary pointer = 269 BYTEs reguard-
                             less of actual index size.  ( see next note )

  The first requested area is the priority sort, the second is the sort under
that, the third under that, etc.

   I've got the indexing for the sort working now, but need a good sort algor-
ithm for the guts.  I'm going to have the procedure decide, based on memory
and index size, wether to sort in memory or disk.

  What I need:

   A fast sort method.  I don't need the actual code ( but would like to see
some :-) ) for sorting Strings, or whatever.  As of now, the index is limited
to a STRING ( IE, 255 bytes ), but I may use an array to increase the size (
although I can't see a sort key over that size!! ).  The major benifit of an
array would of course be a smaller index file and less memory needed for a
memory sort ( since dynamic arrays could be used ).

  I intend to offer an upgrade to the INDEX10.ZIP IndexedFile UNIT that will
allow the program to build an index from the data record with the method I use
to build the sort index here.  The draw back is while this method is fine
 ( even required ) for sorting, it will not garantee a unique index.  Sorting
by nature allows mulitple occurances of records. *sigh*  This is a matter
for the programmer to decide ( it's what we get paid for - right :-) ).  I'll
just export a function to return an index based on numbers as above.

Well,  Hope someone out there can help 'cause I don't have time to dig through
the library for a qwikSort any time soon *sigh*.  I wanted to use the qsort
available with TurboC, but ran into trouble writing the link with TP @#$@% -
any help here would be nice too.

Thanks all,

tom

THOMAS E. JENKINS, JR.

  PROGRAMMER, UNIVERSITY OF SOUTH CAROLINA
    BITNET, C0361 AT UNIVSCVM.BITNET
     INTERNET C0361 AT UNIVSCVM.CSD.SCAROLINA.EDU