Skip to content

Instantly share code, notes, and snippets.

@hashware
Created July 11, 2018 05:22
Show Gist options
  • Save hashware/cd0e4e9ab04bf6bc448c2a02e827f51a to your computer and use it in GitHub Desktop.
Save hashware/cd0e4e9ab04bf6bc448c2a02e827f51a to your computer and use it in GitHub Desktop.
def sort_dict(dict_words):
"""
字典排序
:param dict_words:
:return:
"""
keys = dict_words.keys()
values = dict_words.values()
list_one = [(key, val) for key, val in zip(keys, values)]
list_sort = sorted(list_one, key=lambda x: x[1], reverse=True)
return list_sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment