What are some best practices for sorting data in PHP based on multiple criteria?

When sorting data in PHP based on multiple criteria, one of the best practices is to use the `usort()` function along with a custom comparison function. This allows you to define the logic for sorting based on multiple criteria. Within the comparison function, you can compare the values of the data based on different criteria and return the result accordingly.

$data = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Alice', 'age' => 25],
    ['name' => 'Bob', 'age' => 35],
];

usort($data, function($a, $b) {
    if ($a['age'] == $b['age']) {
        return strcmp($a['name'], $b['name']);
    }
    return $a['age'] - $b['age'];
});

print_r($data);