Monday, 30 September 2013

What should the type of the return value of the key function in sort() be?

What should the type of the return value of the key function in sort() be?

In python, the sort method of lists accepts a key parameter which is a
function.
My question is, what constraints are there on the returned value of key?
Should it be a numeric value? Should it be somehow comparable? Or does
every type of value just work?

No comments:

Post a Comment