Python 3.0, rich comparisons and sorting order

Batista, Facundo FBatista at
Tue Sep 21 19:17:45 CEST 2004

[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: <>

More information about the Python-list mailing list