I wrote a program that should sort the following:
unsorted_list=[['le', 5], ['aab', 4], ['aaa', 5]]
in
[['aaa', 5], ['le', 5], ['aab', 4]]
It must be sorted by number. If the numbers match, then they must be sorted in alphabetical order. I have the following code:
def sortItem(lista): ''' func for sort by item''' return lista[1] sorted(unsorted_list, key=sortItem, reverse=True)
Unfortunately, it does not return a string in alphabetical order. Any suggestion how to do this?
source share