<code><span><span><span><?php
function
quickSort<span>(<span>
$arr
</span>)</span>{
<span>
$count
</span> =
count
<span>(<span>
$arr
</span>)</span>;
if
<span>(<span>
$count
</span> 1</span>)</span>{
return
<span>
$arr
</span>;
}
<span>
$key
</span> = <span>
$arr
</span>[<span>0</span>];
<span>
$left_arr
</span> =
array
<span>()</span>;
<span>
$right_arr
</span> =
array
<span>()</span>;
for
<span>(<span>
$i
</span> = <span>1</span>; <span>
$i
</span>
$count
</span>; <span>
$i
</span>++)</span>{
if
<span>(<span>
$arr
</span>[<span>
$i
</span>]
$key
</span>){
<span>
$left_arr
</span>[] = <span>
$arr
</span>[<span>
$i
</span>];
}
else
{
<span>
$right_arr
</span>[] = <span>
$arr
</span>[<span>
$i
</span>];
}
}
<span>
$left_arr
</span> = quickSort<span>(<span>
$left_arr
</span>)</span>;
<span>
$right_arr
</span> = quickSort<span>(<span>
$right_arr
</span>)</span>;
return
array_merge
<span>(<span>
$left_arr
</span>,
array
<span>(<span>
$key
</span>)</span>,<span>
$right_arr
</span>)</span>;
}
<span>
$arr
</span> =
array
<span>(<span>23</span>,<span>4</span>,<span>6</span>,<span>46</span>,<span>34</span>,<span>23</span>,<span>6234</span>,<span>34</span>,<span>12</span>,<span>34</span>)</span>;
print_r<span>(quickSort<span>(<span>
$arr
</span>)</span>)</span>;</code>