Shuffling elements in an array when 'priority' values are the same?
<p>I have a keyed array, each slot containing two pieces of information: a company name and a priority. I am trying to find a way to shuffle company names that have the same priority value. I am familiar with the shuffle function, however, I don't want to shuffle all elements in the array ignoring the priority values, I would like to ONLY shuffle element that have the same priority value.</p>

<p>Here is an example of what I am trying to do:</p>

<p><strong>Note:</strong> all the following element are in the same array</p>

<pre><code>    McDonalds, 10
    Marshalls, 10
    Dillards,  10
    Burger King, 5
    Hunan Palace, 5
    Taco Bell, 5
    Pizza Hut, 5
    Macy's, 2
    Prudential, 2
    Nike, 2
    Billabong, 2
</code></pre>

<p>I would like to end up with something like:</p>

<pre><code>        Marshalls, 10
        Dillards,  10
        McDonalds, 10
        Hunan Palace, 5
        Burger King, 5
        Pizza Hut, 5
        Taco Bell, 5
        Nike, 2
        Macy's, 2
        Billabong, 2
        Prudential, 2
</code></pre>
