<?
/*
* duplicate normal ordering
/
function compare($left, $right)
{
return($left - $right);
}
//create test data
$some_numbers = array(
"red"=>6,
"green"=>4,
"blue"=>8,
"yellow"=>2,
"orange"=>7,
"cyan"=>1,
"purple"=>9,
"magenta"=>3,
"black"=>5);
//sort using custom compare
uasort($some_numbers, "compare");
//show sorted array
foreach($some_numbers as $key=>$value)
{
print($key. "=". $value. "
\n");
}
?>
uksort(array unsorted_array, string comparison_function)
The uksort function sorts an array using a custom comparison function. Unlike usort,
the array will be sorted by the index values, not the elements. The comparison function
must return a signed integer. If it returns zero, then two indices are considered equal. If a
negative number is returned, the two indices are considered to be in order. If a positive
number is returned, the two indices are considered to be out of order.
<?
/*
* duplicate normal ordering
/
function compare($left, $right)
{
return($left - $right);
}
//create test data
srand(time());
for($i=0; $i<10; $i++)