i have an PHP array in the following format,
Array
(
[0] => Array
(
[40] => 2
[80] => 1
[20] =>
use ksort , which sorts an array by key
Assuming your array is $array
foreach($array as $a){
foreach($a as $sort_me){
ksort($sort_me);
}
}
Use array_combine
(http://php.net/manual/en/function.array-combine.php) to combine the arrays and then use ksort
(http://php.net/manual/en/function.ksort.php) to sort the keys.