title: Is  possible to make the quick sort function sort array descending?
body: <p>I got the following php function, and want to change it into descending sorting, can someone help me: </p>
  
  <pre><code>function quickSort(&amp;$numbers, $array_size,$level)
  {
     q_sort($numbers, 0, $array_size - 1,$level);
  }
  
  
  function q_sort(&amp;$numbers, $left, $right,$level)
  {
     $l_hold = $left;
     $r_hold = $right;
     $pivot = $numbers[$left];
  
  
     while ($left &lt; $right)
     {
        if ($level == 'RegID')
        {
           while (($numbers[$right]-&gt;RegID &gt;= $pivot-&gt;RegID) &amp;&amp; ($left &lt; $right))
              $right--;
        }
  
  
        if ($left != $right)
        {
           $numbers[$left] = $numbers[$right];
           $left++;
        }
  
        if($level == 'RegID')
        {
           while (($numbers[$left]-&gt;RegID &gt;= $pivot-&gt;RegID) &amp;&amp; ($left &lt; $right))
              $left++;
        }
  
  
  
        if ($left != $right)
        {
           $numbers[$right] = $numbers[$left];
           $right--;
        }
     }
  
     $numbers[$left] = $pivot;
     $pivot = $left;
     $left = $l_hold;
     $right = $r_hold;
  
     if ($left &lt; $pivot)
        q_sort($numbers, $left, $pivot-1,$level);
     if ($right &gt; $pivot)
        q_sort($numbers, $pivot+1, $right,$level);
  
  }
  </code></pre>