El siguiente post pertenece al topic: Métodos de Ordenamiento codificados en PHP.
El código realiza un Ordenamiento de datos numéricos haciendo uso del Método de Inserción Directa:
<?php
function insercionDirecta($A,$n)
{
for ($i = 1; $i < $n; $i++)
{
$v = $A[$i];
$j = $i - 1;
while ($j >= 0 && $A[$j] > $v)
{
$A[$j + 1] = $A[$j];
$j--;
}
$A[$j + 1] = $v;
}
return $A;
}
function main()
{
$VectorA=array(5,4,3,2,1);
$VectorB=insercionDirecta($VectorA,sizeof($VectorA));
for($i=0;$i<sizeof($VectorB);$i++)
echo $VectorB[$i]."\n";
}
main();
?>

Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
Wonderful beat ! I would like to apprentice while you amend your
website, how could i subscribe for a blog website? The account helped me
a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept