Building a list of dictionary values, sorted by key
<p>I have a python dictionary that looks something like this:</p>

<pre><code>attributes = {
    'size': ['s','m','l'],
    'color': ['black', 'orange'],
}
</code></pre>

<p>I want to get a list of values. If I use <code>values()</code>, I get this:</p>

<pre><code>&gt;&gt;&gt; attributes.values()
[['black', 'orange'], ['s', 'm', 'l']]
</code></pre>

<p>However, I want the resulting list of lists to be sorted by the dictionary key in reverse order -- ie, size and then color, not color and then size. I want this:</p>

<pre><code>[['s', 'm', 'l'], ['black', 'orange']]
</code></pre>

<p>I do not necesarilly know what the dictionary keys will be beforehand, but I do always know if I want them in alphabetical or reverse alphabetical order.</p>

<p>Is there some pythonic way to do this?</p>

<p>The only thing I can think of seems... not very python-like:</p>

<pre><code>keys = sorted(attributes.keys(), reverse=True)
result = []
for key in keys:
    result.append(attributes[key])
</code></pre>

<p>It's hard to go from <code>attributes.values()</code> to all of that just to sort the list!</p>