[Python] How to sort a list of dictionaries by a value of the dictionary in Python?

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    How do I sort a list of dictionaries by a specific key's value? Given:

    [{'name': 'Homer', 'age': 39}, {'name': 'Bart', 'age': 10}]


    When sorted by name, it should become:

    [{'name': 'Bart', 'age': 10}, {'name': 'Homer', 'age': 39}]

    Continue reading...

Compartilhe esta Página