Sorting a multi-dimensional array by the size of its sub-arrays
Suppose I have an array of arrays, and I want to sort the big array by the # of in开发者_如何学运维dexes in the sub-arrays, what would be the most efficient way to do that?
This is what I have so far
$sortorder = array_map('count', $largearray);
array_multisort($sortorder, $largearray);
Anything better than this?
usort($array, create_function('$a, $b', 'return bccomp(count($a), count($b));'));
精彩评论