Python 3.0, rich comparisons and sorting order
Batista, Facundo
FBatista at uniFON.com.ar
Tue Sep 21 13:17:45 EDT 2004
More information about the Python-list mailing list
Tue Sep 21 13:17:45 EDT 2004
- Previous message (by thread): Python 3.0, rich comparisons and sorting order
- Next message (by thread): Python 3.0, rich comparisons and sorting order
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Carlos Ribeiro] #- For example: today's lists may contain objects of arbitrary types and #- can be sorted; even if the actual ordering may seem arbitrary, it #- works for most purposes. My question is: If Python 3.0 abolishes #- comparison between arbitrary types, how will generic sorting be #- handled? #- #- My guess is that it will not be possible unless you provide a generic #- __cmp__ comparison function (that was the pre-2.1 method, I think). #- The underlying assumption is that heterogeneous lists are #- not supposed #- to be sorted, unless the programmer really knows what he's doing. #- (BTW, for all purposes the same can be said about the use of the new #- key argument provided by 2.4). My guess is that if you have heterogeneous list, and want to sort them, you'll need to pass a function to ``sort()``, which will care about data types and do the right thing. . Facundo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20040921/af3dcdcd/attachment.html>
- Previous message (by thread): Python 3.0, rich comparisons and sorting order
- Next message (by thread): Python 3.0, rich comparisons and sorting order
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list