This is a recursive version of PHP's ksort function.
I tried to make a shorter version of this. What I ended up with isn't necessarily shorter when it's made readable. It becomes a one-liner when the wrapper function is removed and the lines combined:
function ksortRecursive(&$array, $unusedKey, $sortFlags = SORT_REGULAR) {
return is_array($array) && ksort($array, $sortFlags) && array_walk($array, __FUNCTION__, $sortFlags);
}
Unfortunately, array_walk always passes the index to the callback, even though it's not needed here. In this shorter version, one would need to specify some value for the unused key if a sort flag is to be used.