Q: sort's key and cmp parameters

Raymond Hettinger python at rcn.com
Sat Oct 3 08:16:25 CEST 2009


[Paul Rubin]
> 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
> tree.

Can you give an example of a list of trees and a cmp function
that recursively compares them?


Raymond



More information about the Python-list mailing list