标签:
function quick_sort(&$a_data) { if (count($a_data) > 1) { $k = $a_data[0]; $x = array(); $y = array(); $len = count($a_data); for ($i = 1; $i < $len; $i++) { if ($a_data[$i] <= $k) { $x[] = $a_data[$i]; } elseif ($a_data[$i] > $k) { $y[] = $a_data[$i]; } } $x = quick_sort($x); $y = quick_sort($y); return array_merge($x, array($k), $y); } else { return $a_data; } } $a_data = array(20, 40, 60, 80, 30, 70, 90, 10, 50, 0); var_dump(quick_sort($a_data));
标签:
原文地址:http://www.cnblogs.com/huangye-dream/p/5008790.html