将字符串排序后连接起来!
import functools
def cmp(x, y):
if (x + y) > (y + x):
return 1
elif (x + y) < (y + x):
return -1
else:
return 0
n = int(input())
s = input().split( )[:n]
# s.sort(key=functools.cmp_to_key(cmp), reverse=True)
# print(''.join(s).lstrip("0"))
s_new = sorted(s, key=functools.cmp_to_key(cmp), reverse=True)
# s_new = sorted(s, reverse=True)
print(''.join(s_new).lstrip("0"))
3
ac1 cb3 abc dfg2
cb3ac1abc