The uksort function sorts an array by keys using a user-defined comparison function.
function my_sort($x, $y) {
if ($x == $y)
return 0;
return ($x > $y) ? -1 : 1;
}
$languages = array(
"10" => "javascript",
"20" => "php",
"60" => "vbscript",
"40" => "jsp"
);
uksort($languages, "my_sort");
print_r($names);
// Array (
// [10] => javascript
// [20] => php
// [40] => jsp
// [60] => vbscript
// )