Sorting by item_in_another_list
Delaney, Timothy (Tim)
tdelaney at avaya.com
Wed Oct 25 01:37:34 EDT 2006
Fredrik Lundh wrote:
> Delaney, Timothy (Tim) wrote:
>
>> This is a requirement for all implementations claiming to be 2.3 or
>> higher.
>
> the language reference only guarantees this for CPython:
>
> The C implementation of Python 2.3 introduced a stable
> sort() method, but code that intends to be portable across
> implementations and versions must not rely on stability.
http://docs.python.org/lib/typesseq-mutable.html
(9) Starting with Python 2.3, the sort() method is guaranteed to be
stable. A sort is stable if it guarantees not to change the
relative order of elements that compare equal -- this is helpful
for sorting in multiple passes (for example, sort by department,
then by salary grade).
That says pretty strongly to me that it's part of the language
specification. And I'm pretty sure Guido said as much when he
pronounced.
Tim Delaney
More information about the Python-list
mailing list