Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

loop through dictionary in value order python

# Loop through dictionary in value order
di = {'a': 3, 'b': 1, 'c': 2}
tmp = sorted( [(v, k) for k, v in di.items()] )
print(tmp)
# [(1, 'b'), (2, 'c'), (3, 'a')]
 
PREVIOUS NEXT
Tagged: #loop #dictionary #order #python
ADD COMMENT
Topic
Name
9+6 =