I am trying to write a function that given a list of non negative integers, arranges them such that they form the largest possible number.
For example, given
import functools def cmpr(x, y): xy = str(x) + str(y) yx = str(y) + str(x) return -1 if (xy > yx) else 1 a = [50, 2, 1, 9] a.sort(key=functools.cmp_to_key(cmpr))