[Python] Does collection's Counter keeps data sorted?

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I was reading python collections's Counter. It says following:

    >>> from collections import Counter
    >>> Counter({'z': 9,'a':4, 'c':2, 'b':8, 'y':2, 'v':2})
    Counter({'z': 9, 'b': 8, 'a': 4, 'c': 2, 'y': 2, 'v': 2})


    Somehow these printed values are printed in descending order (9 > 8 > 4 > 2). Why is it so? Does Counter store values sorted?

    PS: Am on python 3.7.7

    Continue reading...

Compartilhe esta Página