Why does sorting fail?

I am writing a library procedure that, among other things, will make it rather difficult to sort nested arrays.

The documentation shows that the entire array sorting function (including built-in comparators) can return false on error - but when will it ever be ????

+5
source share
3 answers

This will not work if the variable you are sending to the function is NOT an array
Example:

asort('Hello');//fails
asort(array(1,2,35,7,2,8,3));//true
+8
source

When the supplied parameter is not an array (or maybe even just an empty array).

+1
source

false return examples may include an empty array, a variable, but not an array, insufficient available memory, refusal to call a library, loss of runtime of the sorting module, call parameters are invalid, the disk or disk is offline, the sorting algorithm or method is incompatible with the rules of the region or country development

-1
source

All Articles