list.sort(cmpfunc) question
Aahz Maruch
aahz at panix.com
Fri Mar 16 09:53:46 EST 2001
In article <m1ae6lg5qt.fsf at pclabs188.labs.trema.com>,
Harri Pasanen <harri at trema.com> wrote:
>
>The list.sort(cmp) docs for Python 2.0 state:
>
> The sort() method takes an optional argument specifying a
> comparison function of two arguments (list items) which should
> return -1, 0 or 1 depending on whether the first argument is
> considered smaller than, equal to, or larger than the second
> argument.
Note that "should" carefully. The current implementation of sort() only
checks for a negative value, but that's not a behavior that should be
relied on in your coding. You can be sure that any anamolies in the
behavior of cmp() will be fixed if the sort() algorithm ever changes.
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Three sins: BJ, B&J, B&J
More information about the Python-list
mailing list