I have a list of lists that looks like this [[value, frequency], ... , [value, frequency]]. I wish to sort it in:
- descending order by frequency
- if two frequencies have the same value then I want to sort those lists in ascending order by value.
Example: [[7,1], [8,2], [4,3], [3,2] --sorted--> [[4,3], [3,2], [8,2], [7,1]]
I've tried sorting the list in descending order by frequency like follows:
sorted(list, key=lambda x:x[1], reverse=True)
but this doesn't take care of the second condition
Appreciate the help!