function insertion_sort ($array
{
for$ii=1; $iicount$array); $ii++) {
$value = $array$ii];
$done = false;
$jj = $ii-1;
do {
if ($array$jj] > $value) {
$array$jj+1] = $array$jj];
$jj = $jj-1;
if ($jj<0)
$done = true;
} else {
$done = true;
}
} while (!$done);
$array$jj+1] = $value;
}
return $array
}