Python 3.0, rich comparisons and sorting order

Steven Bethard steven.bethard at
Thu Sep 23 17:36:46 CEST 2004

Alex Martelli <aleaxit <at>> writes:
<snip code masquerading cmp as key> 
> now, anylist.sort(key=masquerade_a_cmp_as_a_key(foo)) should do just the
> same thing (albeit a tad slower) as anylist.sort(cmp=foo), I believe.

Good point.  It also makes the better point that trying to use key= when you 
really want cmp= would be pretty awkward.  And examples like Andrew Dalke's 
file comparator (that compares file size before comparing content) would be 
more awkward to write this way.  (If nothing else, he'd have to use your 
wrapper function.)

I'm convinced. ;)


More information about the Python-list mailing list