Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,21 @@
<?php
function counting_sort(&$arr, $min, $max)
{
$count = array();
for($i = $min; $i <= $max; $i++)
{
$count[$i] = 0;
}
foreach($arr as $number)
{
$count[$number]++;
}
$z = 0;
for($i = $min; $i <= $max; $i++) {
while( $count[$i]-- > 0 ) {
$arr[$z++] = $i;
}
}
}

View file

@ -0,0 +1,10 @@
$ages = array();
for($i=0; $i < 100; $i++) {
array_push($ages, rand(0, 140));
}
counting_sort($ages, 0, 140);
for($i=0; $i < 100; $i++) {
echo $ages[$i] . "\n";
}
?>