sort dictionary of objects
<p>I have a dictionary of objects where the key is a simple string, and the value is a data object with a few attributes.  I'd like to sort my dictionary based on an attribute in the values of the dictionary.  i have used this to sort based on the dictionaries values </p>

<pre><code>sorted = dict.values()
sorted.sort(key = operator.attrgetter('total'), reverse=True)
</code></pre>

<p>This yields a sorted list of values (which is expected) and I lose my original keys from the dictionary (naturally).  I would like to sort both the keys and values together... how can I achieve this?  Any help would be greatly appreciated?</p>
