Official docs: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-compa...
> If you really need the cmp() functionality, you could use the expression (a > b) - (a < b) as the equivalent for cmp(a, b)
> If you really need the cmp() functionality, you could use the expression (a > b) - (a < b) as the equivalent for cmp(a, b)
cmp() is deprecated because there is seldom reason to use it anymore.
E.G:
Sorting words according to their number of letter is just:
You don't return 1, -1 or 0.If you want to rank participants of a game in a dictionary of scores using names as keys and points as values, you would to:
Again you don't return 1, -1 or 0, just the value that is significant. It makes it very, very simple to reason about.