题解 | 字符统计
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
from collections import Counter
s = Counter(input())
resls = list(s.items())
sorted_v = sorted(resls, key= lambda x : (-x[1], x[0]))
for _ in sorted_v:
print(_[0],end='')
先用Counter记录 key 和 个数
然后排序
排序 sorted 的 key lambda 是 x:表示入参 value 表示要比较的结果,如果多个用元组隔开

