<?
$AA = array(30,20,40,10,5,10,30,15);
for( $i = 0; $i < count($AA); $i++ ){
echo $AA[$i]." ";
}
$n = count($AA);
for( $i = 2; $i <= $n; $i++ ){
$Value = $AA[$i];
$j = $i;
While( $AA[$j - 1] > $Value ){
$AA[$j] = $AA[$j - 1];
$j--;
}
$AA[$j] = $Value;
}
?>