I have this dictionary:
dic_kol={"History :":2,"Horror :": 2 ,"Adventure :":1 ,"Comedy :":2 ,"Romance :":2 ,"Action :":3}
Now I want sort dictionary by order of values and if two values was same then sort alphabetically. But required sort numerically ascending and alphabetic descending.
For example in this example output must be:
[('Action :', 3), ('Comedy :', 2), ('History :', 2), ('Horror :', 2), ('Romance :', 2), ('Adventure :', 1)]
But my code is:
print(sorted(dic_kol.items(),key=lambda x: (x[1],x[0]),reverse=True))
And my output is:
[('Action :', 3), ('Romance :', 2), ('Horror :', 2), ('History :', 2), ('Comedy :', 2), ('Adventure :', 1)]