from functools import cmp_to_keyls=['9','23','3','56','78']sorted(ls, key=cmp_to_key(lambda x, y: int(x + y) -int(y + x)))