I have this array:
$routes = array(
array(
\'code\' => \'PZSA\',
\'name\' => \'PLaza san antonio\',
),
array(
\'code\' => \'AVAD\
A little more generic solution where you can just set the key you wish to sort by and it should work for any multidimensional array.
//key to sort by
$sortBy = 'code';
$sorted = array();
foreach($routes as $route) {
foreach($route as $key => $value) {
if(!isset($sorted[$key])) {
$sorted[$key] = array();
}
$sorted[$key][] = $value;
}
}
array_multisort($sorted[$sortBy], SORT_ASC, $routes);
print_r($routes)