From the documentation:
cmp()function should be treated as gone, and the
__cmp__()special method is no longer supported. Use
__hash__(), and other rich comparisons as needed. (If you really need the
cmp()functionality, you could use the expression
(a > b) - (a < b)as the equivalent for
Moreover all built-in functions that accepted the
cmp parameter now only accept the
key keyword only parameter.
Transform an old-style comparison function to a key function. Used with tools that accept key functions (such as
itertools.groupby()). This function is primarily used as a transition tool for programs being converted from Python 2 which supported the use of comparison functions.