标签:++ ret php UNC i++ sort print quic pre
$arr= array(2,13,42,34,56,23,67,365,87665,54,68,3); $info = quick_sort($arr); print_r($info); function quick_sort($arr){ if(count($arr) <= 1){ return $arr; } $left = array(); $right = array(); $middle= $arr[0]; for($i=1;$i<count($arr);$i++){ if($arr[$i] < $middle){ array_push($left,$arr[$i]); }else{ array_push($right,$arr[$i]); } } $left = quick_sort($left); $right = quick_sort($right); $arr2 = array_merge($left,array($middle),$right); return $arr2; }
标签:++ ret php UNC i++ sort print quic pre
原文地址:https://www.cnblogs.com/zh718594493/p/12089222.html