It’s a bit tricky to sort multidimensional arrays in PHP by one of array’s subkeys, but it can absolutely be done. Check it out:
/**
* USING POINTER TO ARRAY - sort an array of arrays with associative indeces by one of those associative values
* @param $array pointer to our array
* @param $subkey associative index that we want to order by
* @param $sort_type [SORT_ASC|SORT_DESC]
* @return void
*/
function sortBySubkey(&$array, $subkey, $sort_type = SORT_ASC) {
foreach ($array as $subarray) {
$keys[] = $subarray[$subkey];
}
array_multisort($keys, $sort_type, $array);
}