Source:
function sort_array_of_arrays(&$array, $key) {
    $sorter=array();
    $ret=array();
    reset($array);
    foreach ($array as $ii => $va) {
        $sorter[$ii]=$va[$key];
    }
    asort($sorter);
    foreach ($sorter as $ii => $va) {
        $ret[$ii]=$array[$ii];
    }
    $array=$ret;
}

Sample Usage:
$myList = array(
    array("title" => "Milk", "priority" => 4),
    array("title" => "Banana", "priority" => 9),
    array("title" => "Sugar", "priority" => 2)
);
sort_array_of_arrays($myList, "priority");

Sort array of associative arrays by specified key.

Pythoneer 4 years ago