[SciPy-dev] fast sorting of most numpy array types
Thu May 7 12:46:37 CDT 2009
On Thu, May 7, 2009 at 12:46, Aahz <firstname.lastname@example.org> wrote:
> On Thu, May 07, 2009, Andrew Schein wrote:
>> I have recently release highly optimized type-specific C routines for
>> sorting arrays of numeric types:
>> The code was motivated in part by noting that the numpy implementation of
>> sort appears to be a template-ized (over comparison) quicksort... and radix
>> sort is often the better choice. Actually, it has been a few months since I
>> looked at the numpy source, so don't quote me. The usort routines use a
>> variety of strategies depending on the size of the array: radix sort, quick
>> sort, insertion sort.
> Speaking as someone who doesn't know anything about NumPy, have you
> looked at the timsort used in Python itself? One of the advantages of
> timsort is that it's guaranteed to be stable (elements that compare equal
> retain their relative ordering from before sorting).
We actually have a few sorting algorithms, including a stable mergesort:
The last time we looked at this, we decided that implementing timsort
probably wouldn't be much better than mergesort. timsort is designed
for the case of expensive compare operations, and we have relatively
Happy to be proven wrong, of course.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Scipy-dev