Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ For example::
>>> c['sausage'] = 0 # counter entry with a zero count
>>> del c['sausage'] # del actually removes the entry

Counters maintain insertion order internally but display from most common to
least common when possible:

>>> c = Counter(a=1, b=2, c=3)
>>> c # display most common to least
Counter({'c': 3, 'b': 2, 'a': 1})
>>> list(c.items()) # original insertion order
[('a', 1), ('b', 2), ('c', 3)]

.. versionadded:: 3.1

.. versionchanged:: 3.7 As a :class:`dict` subclass, :class:`Counter`
Expand Down
Loading