Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is fixed in Python:

The sort() method takes optional arguments for controlling the comparisons.

"key" specifies a function of one argument that is used to extract a comparison key from each list element.

In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function. This is because cmp is called multiple times for each list element while key and reverse touch each element only once.

http://docs.python.org/library/stdtypes.html



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: