How can data be sorted first by one criteria (e.g. street names) and then by another criteria (e.g. numerical values) using array_multisort in PHP?

When using array_multisort in PHP, you can specify multiple arrays to sort by different criteria. To sort data first by one criteria (e.g. street names) and then by another criteria (e.g. numerical values), you can pass both arrays to array_multisort in the desired order. This will first sort the data by the first array and then by the second array.

// Sample data
$streets = ["Main St", "Elm St", "Oak St", "Pine St"];
$values = [5, 3, 8, 1];

// Sort first by street names and then by numerical values
array_multisort($streets, $values);

// Output sorted data
for ($i = 0; $i < count($streets); $i++) {
    echo $streets[$i] . " - " . $values[$i] . "\n";
}