+ 1
How to sort a dictionary in Python in ascending order of their values
Plz urgently answer it it may be tough
7 Respuestas
+ 2
Do you really need the dictionary sorted? Because dictionaries aren't really made for that.
Or do you only want to output the values sorted?
Then you could just write:
print(*sorted(yourdict.values()))
+ 1
Was it really a dictionary? And not a list?
+ 1
If the talk was really about sorting a Python dictionary I find it quite silly tbh.
Somewhat like:
'Please eat your steak cutting with your fork and picking with your knife.'
0
No there was a question in class 11 book to sort a dictionary using basic bubble sort method
0
That's why it's like a challenge
0
Yes a dictionary if you have any doubt you may go through application based questions of ch 10 class 11 sumita arora
0
Let's do it anyway. Sorted output at least.
score = {'Fred': 56,
'Anna': 102,
'Joe': 35}
for i, j in sorted(
[(j,i) for (i,j) in score.items()]):
print(j+':', i)