Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Exakat Blog:
PHP likes sorting too much
Jan 18, 2017 @ 11:03:07

The Exakat blog has a recent post talking about how PHP likes sorting too much, that is, even in some places you're not using specific sort functions, PHP does it for you anyway.

PHP likes to sort. Of course, there is sort(), ksort() and all the cousins. But, PHP actually sorts too much. My first encounter with the problem is the infamous array_unique(). Now, this is also affecting glob() and scandir(). I’m looking for others. Until then, check your code.

He covers the functionality for each of those previously mentioned functions and what kind of sorting they're performing: array_unique, glob and scandir. He ends the post with some quick advice on how to potentially replace these auto-sorting functions and some specific functions to use instead.

tagged: sorting automatic function nonsorting

Link: https://www.exakat.io/php-likes-sorting/