How to add an element to the beginning of an OrderedDict?
There’s no built-in method for doing this in Python 2. If you need this, you need to write a prepend() method/function that operates on the OrderedDict internals with O(1) complexity. For Python 3.2 and later, you should use the move_to_end method. The method accepts a last argument which indicates whether the element will be moved … Read more