how can I sort a bunch of lists over multiple fields?
Steven Bethard
steven.bethard at gmail.com
Wed May 4 13:08:37 EDT 2005
Lonnie Princehouse wrote:
> Non-trivial:
> Any time the user decides to (1) cache intermediary results for a cmp
> function or (2) define a __cmp__ function for the key return value.
> These arise when comparison of partial keys is often sufficient to
> establish order between two objects.
If you want to compare partial keys, often the simplest approach is to
use tuples as keys, with the elements of the tuple being the "parts" of
the key. Python's standard tuple comparison mechanism takes care of the
rest.
STeVe
More information about the Python-list
mailing list