Esempio n. 1
0
 /**
  *  Ordena array
  * 
  */
 function quickSort(&$array, $low, $high, $numeric = false, $key = '', $reverse = false)
 {
     if ($low < $high) {
         $tmpLow = $low;
         $tmpHigh = $high + 1;
         $current = $array[$low];
         $done = false;
         while (!$done) {
             while (++$tmpLow <= $high && OOB_validatetext::isLess($array[$tmpLow], $current, $numeric, $key)) {
             }
             while (OOB_validatetext::isGreater($array[--$tmpHigh], $current, $numeric, $key)) {
             }
             if ($tmpLow < $tmpHigh) {
                 OOB_validatetext::swap($array, $tmpLow, $tmpHigh);
             } else {
                 $done = true;
             }
             //end if
         }
         //end while
         OOB_validatetext::swap($array, $low, $tmpHigh);
         OOB_validatetext::quickSort($array, $low, $tmpHigh - 1, $numeric, $key);
         OOB_validatetext::quickSort($array, $tmpHigh + 1, $high, $numeric, $key);
     }
     //end if
     if ($reverse == ORDER_ASC) {
         $array = array_reverse($array);
     }
 }