Here is a quick look at quick sort.
// Pre: valid array
// Post: returns an array sorted with the quick sort algorithm
function quick_sort($values = array())
{
if(count($values) <= 1)
{
return $values;
}
// we have an array with at least two items to sort
$total_number_of_values = count($values);
$less = array();
$greater = array();
$pivot = $values[0];
// for each element we must loop through the loop
for($j = 1; $j < $total_number_of_values; $j++)
{
if($values[$j] > $pivot)
{
$greater[] = $values[$j];
}
else
{
$less[] = $values[$j];
}
}
return array_merge(quick_sort($less), array($pivot), quick_sort($greater));
}