title: How to have a stable sort in PHP with arsort()?
body: <p>i need to sort an array in php <strong>based on value</strong>, array use some numbers for keys and values, for example like this:</p>
  
  <pre><code>$a = array(70 =&gt; 1 ,82 =&gt; 5  ,61 =&gt; 3 ,55 =&gt; 1 ,34 =&gt; 2 ,53 =&gt; 2 ,21 =&gt; 4 ,13 =&gt; 5);
  </code></pre>
  
  <p><strong>i like to sort it like this</strong>:</p>
  
  <pre><code>Array
  (
      [82] =&gt; 5
      [13] =&gt; 5
      [21] =&gt; 4
      [61] =&gt; 3
      [34] =&gt; 2
      [53] =&gt; 2
      [70] =&gt; 1
      [55] =&gt; 1
  )
  </code></pre>
  
  <p>i used <code>arsort</code> and it worked, but there is a problem because this function make change defult sorted <strong>keys</strong> and sort array to:</p>
  
  <pre><code>Array
  (
      [13] =&gt; 5
      [82] =&gt; 5
      [21] =&gt; 4
      [61] =&gt; 3
      [53] =&gt; 2
      [34] =&gt; 2
      [55] =&gt; 1
      [70] =&gt; 1
  )
  </code></pre>