how php array_multisort work?

前端 未结 3 1605
死守一世寂寞
死守一世寂寞 2020-12-10 18:30

i have some problem to understand array_multisort

See how it sorts when two values are the same:

 $a1=array(\"Dog\",\"Dog\",\"Cat\");
 $a2=array(\"P         


        
3条回答
  •  心在旅途
    2020-12-10 19:21

    If you look at the documentation and the first example, you'll notice that this is the expected behavior.

    With two arguments, both arrays: the first array is sorted; the second array will have its corresponding values re-arranged and sorted if the corresponding values in first column tie. As for your example, think of it as you're doing a SQL ORDER BY Animal, Name:

    1. Cat comes first
    2. The two Dogs have a tie so Fido comes first because Fido < Pluto

提交回复
热议问题