Displaying posts tagged: quicksort
2010-01-20 6:28 pm
No Comments
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) $pivot)
{
$greater[] = $values[$j];
}
else
{
$less[] = $values[$j];
}
}
return array_merge(quick_sort($less), array($pivot), quick_sort($greater));
}
