title: Ordering an array by specific value
body: <p>I have original array like this:</p>
  
  <pre>
  $arr=array(10,8,13,8,5,10,10,12);
  </pre>
  
  <p>and want to sort so finally become:</p>
  
  <pre>
  $arr=array(10,10,10,8,8,13,12,5);
  </pre>
  
  <p>To get final result i using this way:</p>
  
  <pre><code>$arr=array(10,8,13,8,5,10,10,12);
  
  // Remove array that contain array(1)
  $arr_diff=array_diff(array_count_values($arr), array(1));
  
  // Remove array that contain keys of $arr_diff
  $arr=array_diff($arr, array_keys($arr_diff));
  
  // Sort
  rsort($arr);
  ksort($arr_diff);
  
  // unshift
  foreach ($arr_diff as $k=&gt;$v)
  {
      while ($v &gt; 0)
      {
          array_unshift($arr,$k);
          $v--;
      }
  }
  // print_r($arr);
  </code></pre>
  
  <p>My question is there an another more simple way?</p>
  
  <p>Thanks.</p>