HJ102 字符统计
字符统计
http://www.nowcoder.com/questionTerminal/c1f9561de1e240099bdb904765da9ad0
简介易懂的Python解法
import collections while True: try: s = input().strip() c = collections.Counter(s) sorted_items = sorted(c.items(), key=lambda x: (-x[1], x[0])) print(''.join([item[0] for item in sorted_items])) except: break