In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a reverse sorted list of the keys by numerical value (i.e. ['five', 'four', 'three', 'two', 'one']?
Answer
sorted(d.keys(), key=d.__getitem__, reverse=True)
Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a reverse sorted list of the keys by numerical value (i.e. ['five', 'four', 'three', 'two', 'one']?
Answer
?
Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a reverse sorted list of the keys by numerical value (i.e. ['five', 'four', 'three', 'two', 'one']?
Answer
sorted(d.keys(), key=d.__getitem__, reverse=True)
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
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.