cmp() as well as sorted(.., cmp=) does not exist in Python 3.x
anymore. Convert to using sorted(..., key=) instead, which
exists both in Python 2.x and Python 3.x. This isn't caught
in CI because the code is entirely unused.
Change-Id: I44a53291199c77d46c15beeff30b3c186f16cc64