Switch from using cmp to using sorted() with a key func
Remove unused get_http_message_param
Move the encoding down into the Python 3 block
Remove unused import
General clean ups of the compat module