I have a problem to understand array_multisort
See how it is sorted when two values ββare the same:
$a1=array("Dog","Dog","Cat"); $a2=array("Pluto","Fido","Missy"); array_multisort($a1,$a2); print_r($a1); print_r($a2);
Code output above:
Array ( [0] => Cat [1] => Dog [2] => Dog ) Array ( [0] => Missy [1] => Fido [2] => Pluto )
let me know why Missy comes first, if you do ascending, it should be an Array ([0] => Fido, [1] => Missy, [2] => Pluto) for a downward vise
also see this
With sorting options:
$a1=array("Dog","Dog","Cat"); $a2=array("Pluto","Fido","Missy"); array_multisort($a1,SORT_ASC,$a2,SORT_DESC); print_r($a1); print_r($a2);
Code output above:
Array ( [0] => Cat [1] => Dog [2] => Dog ) Array ( [0] => Missy [1] => Pluto [2] => Fido )
but Array ([0] => Missy [1] => Pluto [2] => Fido) is not in SORT_DESC - this is some type of mixing.
can someone explain to me how the multisort array works, so that I can understand how it works.
source share