#先用字典统计字符的个数 #再创建字符数组 #按照次数降序排序. #减去该字母的ASCII码,实现次数相同,按ASCII码的升序输出 while True: try: s = input() dic = {} for c in s: if c not in dic: dic[c] = s.count(c) c_l = list(dic.keys()) c_l.sort(key = lambda x:dic[x] * 1000 - ord(x), reverse = True) print("".join(c_l)) except: break