Sorting an Array by Its Keys
<?php
$dogs = array('A' => 'AA', 'Bud' => 'BB',
'C' => 'D');
ksort($dogs);
printf("<pre>%s</pre>\n", var_export($dogs, TRUE));
krsort($dogs);
printf("<pre>%s</pre>\n", var_export($dogs, TRUE));
$nums = array(15, 2.2, -4, 2.3, 0);
asort($nums);
printf("<pre>%s</pre>\n", var_export($nums, TRUE));
ksort($nums);
printf("<pre>%s</pre>\n", var_export($nums, TRUE));
?>
Related examples in the same category