title: Iterate through Python dictionary by Keys in sorted order
body: <p>I have a dictionary in Python that looks like this:</p>
  
  <pre><code>D = {1:'a', 5:'b', 2:'a', 7:'a'}
  </code></pre>
  
  <p>The values of the keys are mostly irrelevant. Is there are way to iterate through the dictionary by keys in numerical order? The keys are all integers.</p>
  
  <p>Instead of saying</p>
  
  <pre><code>for key in D:
      # some code...
  </code></pre>
  
  <p>Can I go through the dictionary keys in the order <code>1, 2, 5, 7</code>?</p>
  
  <p>Additionally, I cannot use the sort/sorted functions.</p>