Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created November 29, 2018 02:00
Show Gist options
  • Save shiumachi/f4c3a51e6a11d9a7c5a18b5d16210ff3 to your computer and use it in GitHub Desktop.
Save shiumachi/f4c3a51e6a11d9a7c5a18b5d16210ff3 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# Reference: Python Cookbook 2 Ed. p.198
def get_sorted_dict_values(d):
keys = d.keys()
keys.sort()
return [d[key] for key in keys]
if __name__ == '__main__':
d = dict(aaa=100, ddd=600, bbb=300, eee=150, ccc=200)
print(d)
print(get_sorted_dict_values(d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment