Use key instead of cmp, for py3 compatibility

The cmp arg to sort was removed in python3.
Merge branch 'issue33' into develop

* issue33:
  Use key instead of cmp, for py3 compatibility