Is it possible to sort multiple dimensional arrays by multiple columns using the natural look in PHP? Here is an example. Suppose I have a 2D data array, for example,
$array[1]['Name'] = 'John';
$array[1]['Age'] = '20';
$array[1]['Code'] = 'ABC 12';
$array[2]['Name'] = 'John';
$array[2]['Age'] = '21';
$array[2]['Code'] = 'ABC 1';
$array[3]['Name'] = 'Mary';
$array[3]['Age'] = '20';
$array[3]['Code'] = 'ABC 10';
I want to sort this array by name (ASC), then by age (DESC) and by code (ASC), everything will be sorted naturally. Basically it will be array_multisort with natural sorting.
I have found many solutions on this topic on the Internet. Unfortunately, they only support sorting by one column, and not by several columns.
source
share