OrderedDict
Last updated
Last updated
An OrderedDict
is a dictionary subclass that remembers the order that keys were first inserted. The only difference between and OrderedDict()
is that:
OrderedDict preserves the order in which the keys are inserted. A regular dict doesn't track the insertion order, and iterating it gives the values in an arbitrary order. By contrast, the order the items are inserted is remembered by OrderedDict
.
Output: