Jump to content

Sorting algorithms/Shell sort: Difference between revisions

no edit summary
(Change Javascript header to the right text)
No edit summary
Line 893:
output = -5 2 4 7 8 22
</pre>
 
=={{header|PHP}}==
<lang php>
function shellSort($arr)
{
$inc = round(count($arr)/2);
while($inc > 0)
{
for($i = $inc; $i < count($arr);$i++){
$temp = $arr[$i];
$j = $i;
while($j >= $inc && $arr[$j-$inc] > $temp)
{
$arr[$j] = $arr[$j - $inc];
$j -= $inc;
}
$arr[$j] = $temp;
}
$inc = round($inc/2.2);
}
return $arr;
}
</lang>
 
=={{header|PL/I}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.