[Python-Dev] decorate-sort-undecorate

Geoffrey Talvola gtalvola at nameconnector.com
Wed Oct 15 12:03:03 EDT 2003

Guido van Rossum wrote:
>> What about the situation where you want the list sorted in reverse
>> order? If you simply sort and then reverse the list you've broken
>> the stability. 
> ...
> How important do you think this is?  We could punt on the issue,
> implement reverse by reverting the list afterwards.  (I could define
> stability differently and be totally happy with getting everything in
> reverse order rather than only the specified key. :-)

If you make that the documented behavior, then if someone really needs the
items sorted in reverse order, but stable with respect to the original list,
then this will work:

mylist.sort(key=keyfunc, reverse=True)

- Geoff

More information about the Python-Dev mailing list