Mar-31-2018, 08:42 PM
Suppose I have a list of lists:
What if I want to make sure that in cases where 2 entries have the same number they are sorted alphabetically?
I want the numbers descending but the letters ascending. D 34, B 18, C 18, A 5 etc...
How do I do that please?
listA = [['A', 5], ['B', 18], ['C', 18], ['D', 34]I know how to use itemgetter to sort by the second element, the number, in reverse order. D 34, C 18, B 18, A 5 etc...
What if I want to make sure that in cases where 2 entries have the same number they are sorted alphabetically?
I want the numbers descending but the letters ascending. D 34, B 18, C 18, A 5 etc...
How do I do that please?