Created
November 29, 2018 02:00
-
-
Save shiumachi/f4c3a51e6a11d9a7c5a18b5d16210ff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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