title: Python:Extend the 'dict' class
body: <p>I have to solve this exercise:</p>
  
  <blockquote>
    <p>Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the order must be preserved also when new elements are added.</p>
  </blockquote>
  
  <p>How do I extend <code>dict</code>? Do I need to have access to the source code for the <code>dict</code> type?</p>