I am trying to sort an array (with both alphabetic and numeric keys) by keys where the alphabetic keys will come first alphabetically and then numeric keys numerically.
Tried ksort with all the available flags, however that didn't help. Tried several SO answers, but none of them served my purpose. Here is an example of the the array I have..
$array = array(
'Bat' => array(),
'Dog' => array(),
'Apple' => array(),
'Cat' => array(),
1 => array(),
3 => array(),
2 => array(),
4 => array()
);
I need to sort it like this:
$array = array(
'Apple' => array(),
'Bat' => array(),
'Cat' => array(),
'Dog' => array(),
0 => array(),
1 => array(),
2 => array(),
3 => array()
);
What I understand from a SO answer that it might need a custom function to sort using the usort function. That's where I am lost. Any help or guide to the proper direction will be appreciated.
Thanks