Change sorted calls from cmp to key function

Faced some issue in using the sphinx formatter on Python 3.4.

The cmp function is not available in py3 but the key version should already work in py26 and py27.