What are the potential issues with sorting data in PHP using multiple criteria?

When sorting data in PHP using multiple criteria, the potential issue is ensuring that the sorting is done correctly based on all criteria. One way to solve this is by using the `usort` function in PHP, which allows you to define a custom comparison function that considers all criteria when sorting the data.

// Sample array of data to be sorted
$data = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Alice', 'age' => 25],
    ['name' => 'Bob', 'age' => 30],
];

// Custom comparison function for sorting by age first, then by name
usort($data, function($a, $b) {
    if ($a['age'] == $b['age']) {
        return strcmp($a['name'], $b['name']);
    }
    return $a['age'] - $b['age'];
});

// Print the sorted data
print_r($data);