原来python的compare function要回传数值不是bool==
搞了我好久
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
m = {}
for i in range(10):
m[str(i)] = str(mapping[i])
def cmp(n1, n2):
new_n1 = "".join([m[c] for c in str(n1)])
new_n2 = "".join([m[c] for c in str(n2)])
return int(new_n1) - int(new_n2)
return sorted(nums, key=cmp_to_key(cmp))