>> Please use std::stable_sort!
>> std::sort might use random choices when two entries have the same key.
>
> Its the idea that counts, and std::sort doesn't use random choices,

I don't know whether std::sort uses random choices now.
It uses introsort which is based on quicksort.
But even if it is not random now, it might be in the future.

Random choices are common in sorting algorithms.
e.g: a simple quicksort implementation without random choices
performs very poor some data.
Choosing the pivot elements randomly guarantees mostly good
performance for every input.


> its merely that it is unpredictable. Certain algorithms will move
> elements in a manner that makes them unstable, where as others will
> compare like keys and maintain relative order.

Sometimes, yes.  But sometimes randomness is used.
Take std::stable_sort and you're on the safe side.

-- 
Kai Antweiler


_______________________________________________
glob2-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/glob2-devel

Reply via email to