I have an input of two lists: name and age. I want to primarily sort by age (descending), but if there are duplicates of ages, I want to sort those specific duplicate people alphabetically. For example:
name_list = ['Barbara', 'Anna', 'Chloe', 'Debora']
age_list = [31, 31, 45, 50]
Output should be:
['Debora', 'Chloe', 'Anna', 'Barbara'], [50, 45, 31, 31]
I have tried using zip()
and .sort(reverse=True)
. How should I approach this?