title: How to iterate over a Python dictionary in defined order?
body: <p>I'm trying to iterate over a dictionary that I have defined in a specific order, but it always iterates in a different order than what I have defined in my code.  This is just a basic example of what I'm trying to do.  The dictionary I'm iterating over is much larger,  has much more complexly named keys, and is not in alphabetical/numerical order.</p>
  
  <pre><code>level_lookup = \
  {
  'PRIORITY_1' :   { 'level' : 'BAD',   'value' :   ''  },
  'PRIORITY_2' :   { 'level' : 'BAD',   'value' :   ''  },
  'PRIORITY_3' :   { 'level' : 'BAD',   'value' :   ''  },
  'PRIORITY_4' :   { 'level' : 'BAD',   'value' :   ''  },
  'PRIORITY_5' :   { 'level' : 'CHECK', 'value' :   ''  },
  'PRIORITY_6' :   { 'level' : 'CHECK', 'value' :   ''  },
  'PRIORITY_7' :   { 'level' : 'GOOD',  'value' :   ''  },
  'PRIORITY_8' :   { 'level' : 'GOOD',  'value' :   ''  },
  }
  
  for priority in level_lookup:
      if( level_lookup[ priority ][ 'value' ] == 'TRUE' ):
          set_levels += str( priority ) + '\n'
  </code></pre>
  
  <p>I need the order that I define the dictionary in to be preserved during iteration. My order is not alphabetical, so sorting alphabetically wouldn't really help.  Is there any way to do this? I've tried `level_lookup.items(), but that doesn't maintain my order either.</p>