I have a dictionary which has another dictionary as a value. How can I sort it first by key(ascending), and second by the value of the second dictionary(descending)?
my_dict = {'B':{'contest':30, 'contest_two':50, 'contest_three':40}
'A':{'contest_four':50, 'contest_five':60, 'contest_six':70}}
I want to get this :
my_dict = {'A':{'contest_six':70, 'contest_five':60, 'contest_four':50}
'B':{'contest_two':50, 'contest_three':40, 'contest':30 }}
I tried this my_dict = dict(sorted(my_dict.items(), key=lambda x: (x[0],x[1].values()))) but obviously it didnt work.