What potential issues could arise when using a custom sorting function for arrays in PHP?

One potential issue that could arise when using a custom sorting function for arrays in PHP is that the sorting function may not handle all possible edge cases correctly, leading to unexpected results. To solve this issue, it is important to thoroughly test the custom sorting function with various input arrays to ensure its correctness.

// Custom sorting function
function customSort($a, $b) {
    // Add logic for custom sorting here
    return $a - $b; // Example logic, sort in ascending order
}

// Test input array
$array = [3, 1, 2];

// Sort the array using the custom sorting function
usort($array, 'customSort');

// Output sorted array
print_r($array);