Dilwyn Jones writes:

> Many of you will be familiar with the Quicksort recursive sorting
> routine. I wanted to sort large amounts of data at one stage and
> compiled a program containing a recursive routine, which quickly ran
> out of stack space for all the recursion it needed.

Im just in the process of preparing an array toolkit I wrote in the early
'90s for publication on my website (just need to get the documentation
sorted). It includes Quicksort.

<plug>
AFAIK it is very quick and pretty modest in memory consumption - even on a
nearly sorted array. Itll sort "any number" of arrays (or array slices) of 
any type simultaneously, each with its own criteria (up, down or dont care), 
directly or by index only, and even "by reference" (ie the seniority of the 
arrays being sorted neednt be known in advance thus making it "programmable" 
by the user of your program):

    QUICKSORT [index% !] [#]arr1 [; [+|-]comp1% ] {, [#]arr2 [;
[+|-]comp2% ] }

    where
        index%! is an optional list of pointers to the array elements (only
                the index get physically re-arranged when using this option)
        arr1..arrn are arrays of any type (arr2..arrn optional)
        #descriptor$ is a 10byte string containing an optional array
                descriptor instead of an actual array (obtained with the
                function MATINFO$(arr) )
        ;+ | - is the sort direction
        compn% is the sort criteria:
                0 => doesnt affect sort but array is re-arranged with the
                        rest
                1..4 => Qdos type string comparisons 0..3

IIRC the resulting sort is "stable" allowing for an unambiguous fast binary
search (also included) of the array(s) using the same criteria as for the
sort. (That was at least my programming goal. I'll have to check this,
though.)

Itll sort all your sorting problems once and for all, so either wait for it
or request your special copy  (with only basic documentation) now!
</plug>

Per
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to