RE: Sort documentation inaccurate?
by Sean 'Shaleh' Perry other posts by this author
Sep 26 2001 6:12AM messages near this date
Re: Sort documentation inaccurate?
|
scanf style parsing
>
> On closer inspection the documentation says that the compare function is
> supposed to return -1, 0 or 1. However this seems to be either
> unnecessary, inaccurate, or both, since returning zero and one had no
> effect, and returning 0 and -1 sorts the list perfectly.
>
It expects you to write a function similar to C(++)'s strcmp(). It return -1
if x is less than y, 0 if they are equal, and 1 if x is greater than y.
return x < y is either 0 or 1 so you never handle the actual truth of this case
which should return -1.
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Bruce Dawson
Bruce Dawson
Tim Peters
David Glasser
Sean 'Shaleh' Perry
|