Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function selectPivot(array $dataset)
- {
- $x = $dataset[0];
- $y = $dataset[(int)(count($dataset)/2)];
- $z = $dataset[count($dataset)-1];
- if($x>=$y)
- {
- if($y>=$z)
- return [(int)(count($dataset)/2) => $y];
- return $x>=$z
- ?[count($dataset)-1 => $z]
- :[0 => $x];
- }
- if($x>=$z)
- return [0 => $x];
- return $y>=$z
- ?[count($dataset)-1 => $z]
- :[(int)(count($dataset)/2) => $y];
- }
Advertisement
Add Comment
Please, Sign In to add comment