What potential errors or pitfalls can arise when sorting data in PHP?
One potential error when sorting data in PHP is not specifying the correct sorting method, leading to unexpected results. To avoid this, always specify the sorting method (e.g., SORT_ASC or SORT_DESC) when using sorting functions like sort() or rsort().
// Example of sorting an array in ascending order
$data = [3, 1, 2];
sort($data, SORT_ASC);
print_r($data);