Use list.sort(key=foo) param for sorting list in Python 2 and Python 3, not list.sort(cmp=foo)