What are some potential pitfalls when sorting arrays in PHP and how can they be avoided?

One potential pitfall when sorting arrays in PHP is not specifying the sorting method, which can lead to unexpected results. To avoid this, always specify the sorting method (e.g., SORT_REGULAR, SORT_NUMERIC, SORT_STRING) when using sorting functions like `sort()` or `asort()`.

// Example of sorting an array with specified sorting method
$array = [3, 1, 5, 2, 4];
sort($array, SORT_NUMERIC);
print_r($array);