We participate in the Amazon Service LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com

Sorting Associative Arrays in PHP
$arr = [

'foo' => 'bar',
'faz' => 'baz'

];


array_multisort(array_column($arr, 'value'), SORT_ASC, $arr);

You can sort an associative array with one line of code as I did above. As a result, the array becomes sorted by the keys:

[ 
   'faz' => 'baz', 
   'foo' => 'bar' 
]