
However, I'm slightly dubious about the x.sort(lt=f) vs x.sort(cmp=f) technique because it doesn't generalize terribly well.
If I want to write a function that takes a comparison function as an argument, and eventualy passes that function to sort, what do I do? Something like this?
def myfun(foo, bar, lt=None, cmp=None): # ... x.sort(lt=lt, cmp=cmp) # ...
and assume that sort will use None as its defaults also? Or must I write
if lt==None: x.sort(cmp=cmp) else: x.sort(lt=lt)
Either way it's inconvenient.
Given that (if we add this) the cmp argument will be deprecated, myfun() should take a 'lt' comparison only.
So I wonder if it might be better, as a way of allowing sort to take two different types of comparison functions, to distinguish between them by making them different types.
But Python doesn't do types that way. --Guido van Rossum (home page: http://www.python.org/~guido/)