I have the following dictionary.
var = a = { \'Black\': { \'grams\': 1906, \'price\': 2.05}, \'Blue\': { \'grams\': 9526, \'price\': 22.88}, \'Gold\':
import collections update=collections.OrderedDict() result = sorted(a, key=lambda x: (a[x]['price'])) for r in result: update[r]=a[r] print(update)