In which versions is list.sort stable?

Beni Cherniavsky cben at techunix.technion.ac.il
Sun Apr 27 14:17:04 EDT 2003


Aahz wrote on 2003-04-26:

> In article <yyAqa.8330$3M4.231032 at news1.tin.it>,
> Alex Martelli  <aleax at aleax.it> wrote:
> >Magnus Lie Hetland wrote:
> >>
> >> Has list.sort always been stable? Or, if not, in which Python versions
> >> is it not stable?
> >
> >list.sort has not been stable in 1.5.2, 2.0.*, 2.1.*, 2.2.*.  I do not
> >know about previous versions.  Note that list.sort may once again cease
> >being stable (in 2.4.* or further versions) if the timbot dreams up one
> >that's even better on _other_ criteria -- stability's not going to
> >constrain his algorithm choices.
>
> OTOH, Uncle Timmy won't gratuitously remove stability, either.  But I
> still wouldn't bet on Python's sort staying stable past 2.3.
>
Why don't we just grow a `list.stablesort` method that can be an alias
to `list.sort` currently but is guaranteed to be some stable sort
forever?  Explicit is better than implicit, so in the rare case that
you do rely on it, why not spell it out?

-- 
Beni Cherniavsky <cben at tx.technion.ac.il>





More information about the Python-list mailing list