This should be really simple, but what is the way to go on this. I want to sort an multidimensional array by a key, like this:
Array (
[0] => Array
(
I have added this answer at Sort multi-dimensional array by specific key sort the array specific key to sorting array value.
function sortBy($field, &$array, $direction = 'asc')
{
usort($array, create_function('$a, $b', '
$a = $a["' . $field . '"];
$b = $b["' . $field . '"];
if ($a == $b)
{
return 0;
}
return ($a ' . ($direction == 'desc' ? '>' : '<') .' $b) ? -1 : 1;
'));
return true;
}
Call this function by specific array key
sortBy('status', $array);