Python sort dictionary based on value inside a list [duplicate]

I try to sort the following dictionary that contains list as values

Let's say i have this dictionary


x={"George": [68, 0% to work, 70%], "Nikolas": [25, 29% to work, 94%], "Beat": [18, 100% to work, 10%] }


I want to sort this dictionary based on the first value in the list

I want the following list

"Beat": [18, 100% to work, 10%], "Nikolas": [25, 29% to work, 94%], "George": [68, 0% to work, 70%]


Solution 1:

>>> dict(sorted(x.items(), key=lambda item: item[1][0]))

out:

{'Beat': [18, '100% to work', '10%'], 'Nikolas': [25, '29% to work', '94%'], 'George': [68, '0% to work', '70%']}