Sorting on multiple values, some ascending, some descending

dwelden dwoogle at gmail.com
Wed Jan 3 13:48:47 EST 2007


I have successfully used the sort lambda construct described in
http://mail.python.org/pipermail/python-list/2006-April/377443.html.
However, how do I take it one step further such that some values can be
sorted ascending and others descending? Easy enough if the sort values
are numeric (just negate the value), but what about text?

Is the only option to define an external sorting function to loop
through the list and perform the comparisons one value at a time?




More information about the Python-list mailing list