I have an array such as:
Array ( [DEF] => Array ( [0] => Array ( [type] => 1
Using uksort:
uksort($array, function($a, $b) { return count($b) - count($a); });
Using array_multisort:
array_multisort
array_multisort(array_map('count', $array), SORT_DESC, $array);
With PHP < 5.3:
function sort_cb($a, $b) { return count($b) - count($a); } uksort($array, 'sort_cb');