Perl-Python-a-Day: Sorting
Tim Roberts
timr at probo.com
Sat Oct 15 13:39:35 EDT 2005
Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
>Abdulaziz Ghuloum <aghuloum at c-s-remove-dashes.indiana.edu> writes:
>
>> Python FAQs contain an entry to the schwartzian transform.
>>
>> http://www.python.org/doc/faq/programming.html#i-want-to-do-a-complicated-sort-can-you-do-a-schwartzian-transform-in-python
>
>This entry is obsolete: it should mention the 'key' option of the
>standard sort method.
It should mention it, but not necessarily recommend it.
I haven't run the numbers in Python, but in Perl, the undecorated sort is
so well-optimized that the Schwartzian transform is almost always faster
than passing a custom comparator to the sort function.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list