ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved