Remove use of `cmp` since it was removed from Python 3