Python dictionary storage
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3469633/ordering-in-python-dictionary">Ordering in Python (2.4) dictionary</a>  </p>
</blockquote>



<p>I tried to copy a <code>dict</code> to another but in a sorted way. I got the follwing problem.</p>

<pre><code>mydict = {'carl':40,           
          'alan':2,           
          'bob':1,           
          'danny':3}
d1={}
for key in sorted(mydict):
    d1[key]=mydict[key]
</code></pre>

<p>When I print <code>d1</code> it shows:</p>

<pre><code>{'bob': 1, 'danny': 3, 'carl': 40, 'alan': 2}
</code></pre>

<p>Why is it not in sorted order?</p>
