What are the best practices for sorting arrays with multiple keys in PHP?
When sorting arrays with multiple keys in PHP, you can use the `array_multisort()` function to sort the array based on multiple keys. This function allows you to specify the array to be sorted as well as the keys to sort by. You can sort the array in ascending or descending order based on the keys provided.
// Example of sorting an array with multiple keys in PHP
$data = array(
array('name' => 'John', 'age' => 30),
array('name' => 'Jane', 'age' => 25),
array('name' => 'Alice', 'age' => 35),
);
// Sort the array by name in ascending order, then by age in descending order
array_multisort(array_column($data, 'name'), SORT_ASC, array_column($data, 'age'), SORT_DESC, $data);
// Output the sorted array
print_r($data);