Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var={'rank':[2,4,1,3]}

#how to order the rank key variable for your reference see below output

#{'rank':[1,2,3,4]}

What I have tried:

I have tried sorted(var.values()) but it is not giving exact output.
Posted
Updated 27-Mar-21 4:36am

1 solution

Python
var={'rank':[2,4,1,3]}
var['rank']=sorted(var['rank'])

See 5. Data Structures — Python 2.7.18 documentation[^].
 
Share this answer
 
Comments
Maciej Los 29-Mar-21 5:25am    
5ed!
Richard MacCutchan 29-Mar-21 5:41am    
Thanks, I see you are following me again. :)
Maciej Los 29-Mar-21 6:50am    
:DI do and i'll do it again and again...
:D
Richard MacCutchan 29-Mar-21 7:06am    
:))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900