Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Another example
keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
d = {}
for x in keys:
d[x] = x
d2 = {}
for x in keys:
d2[x] = x
# This does not guarantee that order of d_sorted will match d2 !!!
d_sorted = {x:d[x] for x in d2.keys()}
# Output will be different
print(d_sorted.values())
print(d2.values())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment