In Python3, `cmp` is deprecated. It would probably be good to make use of an underlying data structure library that uses rich comparison methods ([demonstrated here](https://stackoverflow.com/a/8277028)).