If you want to avoid looping, you can use the array_column function to achieve your goal. For example,
You want to sort the array below with sorting by distance
$arr = array( 0 => array( 'lat' => 34, 'distance' => 332.08 ), 1 => array( 'lat' => 34, 'distance' => 5 ), 2 => array( 'lat' => 34, 'distance' => 34 ) );
Using one line below, your array will be sorted by distance
array_multisort( array_column( $arr, 'distance' ), SORT_ASC, SORT_NUMERIC, $arr );
Now $ arr contains a sorted array by distance
Chirag viradiya
source share