How to sort a complex nested dictionary to a nested list
<p>What is the best way to sort a nested dictionary in Python 2.6 by value? I would like to sort by the length of the inner dictionary followed by the inner dictionary with the largest value. For example:</p>

<pre><code>d = {1: {'AA': {'a': 100, 'b': 1, 'c': 45}},
     2: {'AA': {'c': 2}},
     3: {'BB': {'d': 122, 'a': 4, 't': 22, 'r': 23, 'w': 12}},
     4: {'CC': {'y': 12, 'g': 15, 'b': 500}}}
</code></pre>

<p>The desired solution is a nested list:</p>

<pre><code>lst = [[3, 'BB', {'d': 122, 'a': 4, 't': 22, 'r': 23, 'w': 12}],
       [4, 'CC', {'y': 12, 'g': 15, 'b': 500}],
       [1, 'AA', {'a': 100, 'b': 1, 'c': 45}],
       [2, 'AA', {'c': 2}]]
</code></pre>
