This is because this function means "I really don't care how they are sorted, they are equal to me." With this simple example, I get an inverse array:
function sortaaa($a,$b) {return 0;} $array = array(1,2,3,4,5); usort($array,"sortaaa"); var_dump($array); //prints array(5) { [0]=> int(5) [1]=> int(4) [2]=> int(3) [3]=> int(2) [4]=> int(1) }
So, it looks like PHP is accessing the array in reverse order in the usort function. So, look at the usort manual claims that
If two members are compared as equal, their order in the sorted array is undefined.
source share