- function quicksortX(&$seq)
- {
- $stack = array($seq);
- $sort = array();
- while ($stack) {
- $arr = array_pop($stack);
- if(count($arr) if (count($arr) == 1) {
- $sort[] = &$arr[0];
- }
- continue;
- }
- $k = $arr[0];
- $x = array();
- $y = array();
- $_size = count($arr);
- for ($i = 1; $i if ($arr[$i] $x[] = &$arr[$i];
- } else {
- $y[] = &$arr[$i];
- }
- }
- !empty($y) && array_push($stack, $y);
- array_push($stack, array($arr[0]));
- !empty($x) && array_push($stack, $x);
- }
- return $sort;
- }
复制代码
|