Q: sort's key and cmp parameters
Sat Oct 3 06:11:22 CEST 2009
Raymond Hettinger <python at rcn.com> writes:
> I'm not sure what you mean by this. What are the semantics of
> sorting a tree? Can you outline an example of tree that
> could be sorted easily with a cmp function but not a key function?
The idea was that you have a list of trees that you want to sort, and
an ordering relation between trees:
def gt(tree1, tree2): ...
where you recursively descend both trees until you find an unequal
pair of nodes. You're not trying to sort the nodes within a single
More information about the Python-list