Php array sorting has just been in contact with php for three days. the previous programming experience is zero, so this is really a small problem. I have searched the internet and have not found a solution T_T,
I'm in a hurry. I 'd like to ask for help.
Suppose I have an array like this:
$ A [0] [0] = "3499230933 ";
$ A [0] [1] = 9.25;
$ A [1] [0] = "4499230933 ";
$ A [1] [1] = 9.25;
$ A [2] [0] = "2499230933 ";
$ A [2] [1] = 10;
$ A [3] [0] = "1499230933 ";
$ A [3] [1] = 9.70;
$ A [4] [0] = "6499230933 ";
$ A [4] [1] = 9.45;
$ A [5] [0] = "5499230933 ";
$ A [5] [1] = 9.27;
I want it to sort by the value of $ [] [1]. the expected sorting result is as follows:
$ A [2] [0] = "2499230933 ";
$ A [2] [1] = 10;
$ A [3] [0] = "1499230933 ";
$ A [3] [1] = 9.70;
$ A [4] [0] = "6499230933 ";
$ A [4] [1] = 9.45;
$ A [5] [0] = "5499230933 ";
$ A [5] [1] = 9.27;
$ A [0] [0] = "3499230933 ";
$ A [0] [1] = 9.25;
$ A [1] [0] = "4499230933 ";
$ A [1] [1] = 9.25;
Reply to discussion (solution)
$a[0][0]="3499230933";$a[0][1]=9.25;$a[1][0]="4499230933";$a[1][1]=9.25;$a[2][0]="2499230933";$a[2][1]=10;$a[3][0]="1499230933";$a[3][1]=9.70;$a[4][0]="6499230933";$a[4][1]=9.45;$a[5][0]="5499230933";$a[5][1]=9.27;foreach($a as $v) $r[] = $v[1];array_multisort($r, SORT_DESC, $a);print_r($a);
Array( [0] => Array ( [0] => 2499230933 [1] => 10 ) [1] => Array ( [0] => 1499230933 [1] => 9.7 ) [2] => Array ( [0] => 6499230933 [1] => 9.45 ) [3] => Array ( [0] => 5499230933 [1] => 9.27 ) [4] => Array ( [0] => 3499230933 [1] => 9.25 ) [5] => Array ( [0] => 4499230933 [1] => 9.25 ))
Thank you very much. thank you very much.