I have the below code:
lst = [['candy','30'], ['apple','10'], ['baby','20'], ['baby','10']]
lst.sort(key=lambda x: (x[1], x[0]))
print(lst)
With this the output is:
[['apple', '10'], ['baby', '10'], ['baby', '20'], ['candy', '30']]
I'm trying to display the names in Descending order while the values in Ascending order. Is there a pre built way in python to achieve this?
Expected output:
[['baby', '10'], ['apple', '10'], ['baby', '20'], ['candy', '30']]