You are viewing a single comment's thread. Return to all comments →
php:
$pivot = $arr[0]; $n = count($arr); $left = $right = $equal = []; for($i=0;$i<$n;$i++){ if($arr[$i] == $pivot){ $equal[] = $arr[$i]; }else if($arr[$i] < $pivot){ $left[] = $arr[$i]; }else{ $right[] = $arr[$i]; } } $result = array_merge($left,$equal,$right); return $result;
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 1 - Partition
You are viewing a single comment's thread. Return to all comments →
php: