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



<p>I tried to copy a dict to another but in 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 d1 it shows:</p>

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

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