On Sat, Jul 24, 2010 at 11:54 AM, Rob Beezer <goo...
> So it is a verb. ;-)
> Looks like similar comments apply to edges().
> I'm thinking that optionally passing in a comparison function would be
> a nice thing to add - a minor convenience, but also it would drive
> home the point that the sorting is somewhat the caller's
> responsibility in non-trivial situations (ie for not most users).
> I'll get a ticket started soon.
Note that Python 3 has removed the comparison function argument for
List.sort() and similar functions, in favor of a "key" argument giving
a function that transforms a list element into a sortable element.
For example, if you want to sort by string representations, currently
you could do:
verts.sort(cmp=lambda a, b: cmp(str(a), str(b)))
but in Python 3 you would have to do:
The idea is to discourage inefficient programming; the Python 3
version is better, because it calls str() on each element only once,
whereas the old version calls str() on each element O(log(N)) times.
Our current Python also has a key= argument for sort().
I suggest that we should follow Python 3 here for such APIs, and
optionally pass in a key= function rather than a cmp= comparison