1
Suppose I have the following list of dictionaries:
lista = [{"nome": "Maria", "idade": 15},
{"nome": "João", "idade": 26}]
And I’m using the following function to sort:
ordenar = sorted(lista, key=itemgetter("idade"))
But I just want you to present me the names in the descending order of age, from the highest to the lowest, ie: ["João", "Maria"]
without presenting me with the entire dictionary.
Thank you! it worked fine, just one more question, in case I wanted to order by one but show both columns, how would it look?
– Carol
I added another example showing how Sort can be done with more than one column.
– Icaro Martins