Just as an example how to sort by first name and then by last name with the sort helper of Laravel.
First define some more example data:
$array = array(
array('firstname_1','lastname_1'),
array('firstname_2','lastname_3'),
array('firstname_2','lastname_2'),
array('firstname_3','lastname_3'),
);
In our closure we want to sort by first name first, and then by last name. Laravel will sort by the returned values of the closure. So in your case the trick is to concatenate both strings:
$array = array_sort($array, function($value) {
return sprintf('%s,%s', $value[0], $value[1]);
});
Internally Laravel will now sort the contents of this intermediate array:
$intermediateArray = array(
'firstname_1,lastname_1',
'firstname_2,lastname_3',
'firstname_2,lastname_2',
'firstname_3,lastname_3',
);
This will result in an array which is sorted by first name and than by last name in ascending order.
To use descending order you need first sort the array and than reverse it:
$array = array_reverse(array_sort($array, function($value) {
return sprintf('%s,%s', $value[0], $value[1]);
}));