= $size || $start_index > $end_index) { throw new Exception("index out of bounds"); } //Het stopcriterium if($end_index === $start_index){ return; } //Voer partitie uit op basis van pivot $pivot_index = partition($list, $start_index, $end_index); //Als er nog een lijst links van de pivot over is: sorteer deze if($start_index < $pivot_index - 1) { quick_sort($list, $start_index, $pivot_index - 1); } //Als er nog een lijst rechts van de pivot over is: sorteer deze if($pivot_index + 1 < $end_index) { quick_sort($list, $pivot_index + 1, $end_index); } } //Test $list1 = array(3,4,1,2,7,3,9,5); quick_sort($list1); print_r($list1);