Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?

[v for (k,v) in sorted(d.items())]

^^^ also accurate is: [d[x] for x in sorted(d.keys())]

Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?
?

Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?

[v for (k,v) in sorted(d.items())]

^^^ also accurate is: [d[x] for x in sorted(d.keys())]

If you want to change selection, open document below and click on "Move attachment"

pdf

owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p56

Summary

status measured difficulty not learned 37% [default] 0

No repetitions