On Python 2, the comparison falls back to the default sort order for dictionaries (Counter
is a subclass of dict
).
Mappings (dictionaries) compare equal if and only if their sorted
(key, value) lists compare equal. [5] Outcomes other than equality are
resolved consistently, but are not otherwise defined. [6]
On Python 3, the comparison raises a TypeError
:
Mappings (dictionaries) compare equal if and only if they have the
same (key, value) pairs. Order comparisons (‘<‘, ‘<=’, ‘>=’, ‘>’)
raiseTypeError
.