josh logan wrote: > A better example would be sorting by increasing last name and > decreasing first name. This would be easy with the sort function > comparator, but I can't see how to do the same with the key argument. > Is the only solution to decorate the Player objects in another class > that has the appropriate __cmp__ function (or whatever is needed) and > then retrieve the Player objects back?
Python's sort algorithm is guaranteed to be stable; therefore you can sort twice: ordered = sorted(players, key=lambda p: p.fname, reverse=True) ordered.sort(key=lambda p: p.lname) Peter -- http://mail.python.org/mailman/listinfo/python-list