What is the best practice for sorting query results in PHP when comparing multiple columns?

When sorting query results in PHP based on multiple columns, it is best to use the `array_multisort()` function. This function allows you to sort an array of results based on multiple columns in a specific order. By specifying the columns and sorting direction, you can easily achieve the desired sorting outcome.

// Example code for sorting query results in PHP based on multiple columns
// Assuming $results is an array of query results

// Extract the columns to be sorted
foreach ($results as $key => $row) {
    $column1[$key] = $row['column1'];
    $column2[$key] = $row['column2'];
}

// Sort the results based on multiple columns
array_multisort($column1, SORT_ASC, $column2, SORT_DESC, $results);

// Now $results will be sorted based on column1 in ascending order and column2 in descending order