Q: sort's key and cmp parameters
ethan at stoneleaf.us
Thu Oct 1 20:21:38 CEST 2009
Laszlo Nagy wrote:
>>> can be achieved (to a very good approximation at least) with
>>> scrambled = some_list.sort(key=lambda x: random())
>>> Is there a real-life sorting task that requires (or is far more
>>> efficient with) cmp and can't be easily achieved with key and
>> The core developers don't think there is one. list.sort() no longer
>> supports the cmp parameter in 3.x.
> LOL :-D
> BTW if you really want to sort a list then you can. Using keys or
> values, it doesn't matter. The op's question has no practical usage.
> REALLY looks like a homework.
If it is, it's one he's contemplating giving his students. :-D
More information about the Python-list