Paul Rubin wrote:
Ben Finney <ben+pyt...@benfinney.id.au> writes:
So how should I be sorting a list with entries of “unequal types” such
that it will work in Python 3?
Um, what ordering do you want? Basically you have to write a custom key
function (they removed the option of writing a comparison function).
Maybe something like
foo.sort(key=lambda x: (type(x), x))
would be enough to fool the sorting function? I don't have python 3
so I haven't tried it.
You can't compare types:
TypeError: unorderable types: type() < type()
but you can compare their names.
--
http://mail.python.org/mailman/listinfo/python-list