Laurence Reeves writes:

>>>> 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.)
>>>>
>>>>
>>> Sorry? I don't think I follow your banter. A stable sort is one where
>>> records with equal keys remain in the same order after the sort as they
>>> were before it. I'm certain that quicksort cannot do that.
>>>
>>
>> You are, of course, right. However the routine can be made to simulate a
>> stable sort by using an additional array:
>>
>> If array$ contains an array to sort and an additional array stabiliser% 
>> is
>> initialised to 0,1,2,..dimn(array$), then
>>
>>     QUICKSORT array$; 1, stabiliser%; 1
>>
>> produces a stable sort.
>>
>>
> This is, of course, cheating. You have NOT made the sort stable. What
> you have done is to make the keys unique.

In love, war and programming, surely, anything that does the trick can never 
be called cheating. Quicksort is so much faster than any stable sort I know 
of, even when "cheating", that its worth it  ;o)

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

Reply via email to