What are some alternative approaches to sorting arrays in PHP besides using array_multisort?

One alternative approach to sorting arrays in PHP is to use the usort() function. This function allows you to define a custom comparison function to determine the sorting order of the elements in the array.

// Define a custom comparison function
function customSort($a, $b) {
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}

// Sort the array using the custom comparison function
$array = [3, 1, 2];
usort($array, 'customSort');

print_r($array);