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 Heapsort:
<?php
function heapsort($A,$n)
{
for($k=$n-1;$k>=0;$k--)
{
for($i=1;$i<=$k;$i++)
{
$item=$A[$i];
$j=$i/2;
while($j>0 && $A[$j]<$item)
{
$A[$i]=$A[$j];
$i=$j;
$j=$j/2;
}
$A[$i]=$item;
}
$temp=$A[0];
$A[0]=$A[$k];
$A[$k]=$temp;
}
return $A;
}
function main()
{
$VectorA=array(5,4,3,2,1);
$VectorB=heapsort($VectorA,sizeof($VectorA));
for($i=0;$i<sizeof($VectorB);$i++)
echo $VectorB[$i]."\n";
}
main();
?>

Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your article helped me a lot, is there any more related content? Thanks!
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Muchas gracias por compartir.
Prueba 3 71 90 3 96 1 5 1 -8 20 25 39 2 5 -1 7
Ordenado -8 -1 1 1 2 3 3 5 5 7 20 25 39 71 90 96
Resultado satisfactorio.
como quedaría
la prueba de escritorio?
quiero con diapositivas y explicaCIONES