Sort a hash table (dictionary)

For example: sort the following values ​​of a dictionary in descending order

hash_idct={'如何挂失身份证?': 114, '住房公积金的到账时间?': 320, '失业金': 18, 
'失业补助金什么时候可以下发到个人?': 1, '失业金领取标准': 1}

Ideas:

Using lambda and python built-in function sorted() :

result=sorted(hash_dic.items(),key=lambda x:x[1],reverse=True)

 

Guess you like

Origin blog.csdn.net/weixin_38664232/article/details/108779234