I want to iterate through the keys of a dictionary which is sorted with values. one method is to use ordered dictionary means initialize dictionary with sorted values.
code:
from collections import OrderedDict
data = OrderedDict([('a',0), ('d',1), ('c',2), ('b',3)])
for mykey in data:
print mykey
How can i achieve this without using Ordered dictionary ? I know that above was correct method to achieve this, i just want to know can we do the same without using Ordered dictionary.
sorted(dictionary.values)
will give me only sorted list of values not whole dictionary with sorted values so i can't have keys here.