Custom Sorting Python Dictionary
<p>So I have a dictionary that looks like this when I print it:</p>

<pre><code>{'10': -10, 'ZT21': 14, 'WX21': 12, '2': 15, '5': -3, 'UM': -25}
</code></pre>

<p>I want to sort these in a custom manner, which I define. Let's say the way I want it to be sorted (by key) is <code>ZT21</code>, <code>10</code>, <code>WX21</code>, <code>UM</code>, <code>5</code>, <code>2</code>.</p>

<p>Anyone know how to go about sorting out a dictionary in a predefined/custom manner? What I am doing is getting this dictionary from a database, and it can come out with over 20 keys, all of which have a specific order. The order is always set, but sometimes certain keys/values wouldn't be in the dictionary. So this could happen too:</p>

<pre><code>{'ZT21': 14, 'WX21': 12, '2': 15, '5': -3, 'UM': -25}
</code></pre>

<p>sorted (by key) is <code>ZT21</code>, <code>10</code>, <code>WX21</code>, <code>UM</code>, <code>5</code>, <code>2</code>.</p>

<p>So the 10 isn't there in this example, but the sorting I need is still the same, the 10 would just be absent.</p>

<p>Any ideas?</p>
