I'm trying to compare things in list, tuple, etc. and I'm wondering how we specify what we want to compare. I want to sort a list: [('A',(6,2,1,3)), ('B',(4,5,9,3)), ('C',(1,2,3,8))] by the last number, and if the last number is equal, then sort by the 3rd number. However, I'm unsure how to approach this. I used lambda to sort by the last number, but when the last numbers are equal, python automatically sorts by the first number.
Add a comment
|