python 字母频次

问题遇到的现象和发生背景

1:如何用Python实现输入的字符串所出现的各字母频率排序(降频排序)?2:相同频率的字母按照字母表顺序排列
(不使用插件的情况下)

img

用代码块功能插入代码,请勿粘贴截图
def count_frequency(text):
    chars = []
    ret = []

    for char in text:
        if char in chars:
            continue
        else:
            chars.append(char)
            ret.append((char, text.count(char)))

    return ret

我想要达到的结果

img

text = input()
cnt = dict()
for i in text:
    cnt[i] = cnt.get(i,0)+1
res = sorted(sorted(cnt.items()),key=lambda x:x[1])
print(res)

最后要看怎么输出了