I am looking for a way to sort a dictionary by values. But here is the catch, my values are dictionaries as well. So I want to sort by my value dictionary's first value.
For example given the dictionary:
x = {'a':{'b':1, 'c':2, 'd':3}, 'e':{'f':3, 'g':4, 'h':5}, 'i':{'j':2, 'k':3, 'l':4}}
I would like the dictionary to be sorted by the values 'b', 'f', and 'j'. The sorted dictionary would return as:
x = {'a':{'b':1, 'c':2, 'd':3}, 'i':{'j':2, 'k':3, 'l':4}, 'e':{'f':3, 'g':4, 'h':5}}
Any help would be amazing. Preferably, I am looking for a solution that uses the sorted method along with lambdas.