3 ms·
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 t
by tantalor 14y ago
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 http://docs.python.org/library/stdtypes.html