Naturally sort a multi-dimensional array by key
Check out strnatcmp(); This is a natural sort by key function using it:
function knatsort(&$arr){return uksort($arr,function($a, $b){return strnatcmp($a,$b);});}
Works in place with the speed and return value of uksort. Use it like this:
knatsort($array);
:)
Something simpler. Extract the array keys and sort those, sorting the original by that:
array_multisort(array_keys($array), SORT_NATURAL, $array);
With case insensitivity:
array_multisort(array_keys($array), SORT_NATURAL | SORT_FLAG_CASE, $array);