python randomly sort items of the same value
<p>This is a bit tricky and I couldn't come up with anything concise. </p>

<p>I have a list of tuples sorted by an item of the tuple. It's possible for these items to have the same value, so something like this:</p>

<pre><code>a = [(a,1), (b,1), (c, 1), (d,2), (e,2), (f,2)]
</code></pre>

<p>What I'm looking for, is a way to randomize the order of all the 1's and 2's within their own sets. This is to replace a bit of mysql:</p>

<pre><code>ORDER BY num_of_hotdogs DESC, rand()
</code></pre>
