Use "key" parameter for sort instead of "cmp"

The "cmp" parameter is not supported in Python 3 anymore.