sort nested defaultdict within a list of dictionaries
<p>Having trouble wrapping my head around how to order this list which consists of nested defaultdicts. I was able to sort by 'registration' key and the 'classes' value with this;</p>

<pre><code>sorted(dict1.items(), key=itemgetter(1), reverse=True)
</code></pre>

<p>Which produced;</p>

<p><code>[('registration', {'count': 11, 'classes': Counter({'class1': 5, 'class2': 5, 'class3': 1}), 'date': defaultdict(&lt;function date_record at 0x7fc173646500&gt;, {datetime.date(2016, 6, 7): {'count': 1, 'hour': Counter({16: 1})}, datetime.date(2016, 6, 6): {'count': 10, 'hour': Counter({16: 5, 14: 2, 8: 1, 10: 1, 12: 1})}})})]</code></p>

<p>However now I'm trying to sort by 'date' which is a nested defaultdict. I'm trying to order by the date chronologically (from - to) and then finally, order the 'hour' Counter() chronologically (for reference; 8 = 8am, and 16 = 4pm). </p>

<p>So the above defaultdict should look like this;</p>

<p><code>[('registration', {'count': 11, 'classes': Counter({'class1': 5, 'class2': 5, 'class3': 1}), 'date': defaultdict(&lt;function date_record at 0x7fc173646500&gt;, {datetime.date(2016, 6, 6): {'count': 10, 'hour': Counter({16: 5, 14: 2, 12: 1, 10: 1, 8: 1})}, datetime.date(2016, 6, 7): {'count': 1, 'hour': Counter({16: 1, 14: 4})}})})]</code></p>

<p>I'm just having trouble figuring out how to access the defaultdict. Any guidance on how I can access it within a sort?</p>