我有一个数组结构
Array
(
[0] => Array
(
[0] => 97
[1] => 155
[2] => 160
[3] =>
)
[1] => Array
(
[0] => 97
[1] => 155
[2] => 161
[3] =>
)
[2] => Array
(
[0] => 97
[1] => 155
[2] => 572
[3] =>
)
[3] => Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => Responds when talked to, for example, moves arms and legs, changes facial expression, moves body and makes mouth movements.
)
[4] => Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => Recognises and is most responsive to main carer's voice: face brightens, activity increases when familiar carer appears.
)
[5] => Array
(
[0] => 97
[1] => 155
[2] => 156
[3] => Makes own sounds in response when talked to by familiar adults.
)
[6] => Array
(
[0] => 97
[1] => 155
[2] => 156
[3] => Practises and gradually develops speech sounds (babbling) to communicate with adults; says sounds like 'baba, nono, gogo'.
)
[7] => Array
(
[0] => 356
[1] => 405
[2] => 406
[3] => Gets to know and enjoy daily routines, such as getting-up time, mealtimes, nappy time, and bedtime.
)
[8] => Array
(
[0] => 356
[1] => 405
[2] => 407
[3] => Attempts, sometimes successfully, to fit shapes into spaces on inset boards or jigsaw puzzles.
)
[9] => Array
(
[0] => 356
[1] => 405
[2] => 407
[3] => Uses blocks to create their own simple structures and arrangements.
)
)
我用
<?php
foreach( $arr as $key => $value ) {
$a[$key] = $value[3];
$b[$key] = $value[2];
$c[$key] = $value[1];
$d[$key] = $value[0];
}
array_multisort($a, SORT_ASC, $b , SORT_ASC, $c, SORT_DESC, $d, SORT_ASC, $a);
?>
结果是
Array
(
[0] => Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => Recognises and is most responsive to main carer's voice: face brightens, activity increases when familiar carer appears.
)
[1] => Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => Responds when talked to, for example, moves arms and legs, changes facial expression, moves body and makes mouth movements.
)
[2] => Array
(
[0] => 97
[1] => 155
[2] => 156
[3] => Makes own sounds in response when talked to by familiar adults.
)
[3] => Array
(
[0] => 97
[1] => 155
[2] => 156
[3] => Practises and gradually develops speech sounds (babbling) to communicate with adults; says sounds like 'baba, nono, gogo'.
)
[4] => Array
(
[0] => 97
[1] => 155
[2] => 160
[3] =>
)
[5] => Array
(
[0] => 97
[1] => 155
[2] => 161
[3] =>
)
[6] => Array
(
[0] => 356
[1] => 405
[2] => 406
[3] => Gets to know and enjoy daily routines, such as getting-up time, mealtimes, nappy time, and bedtime.
)
[7] => Array
(
[0] => 356
[1] => 405
[2] => 407
[3] => Attempts, sometimes successfully, to fit shapes into spaces on inset boards or jigsaw puzzles.
)
[8] => Array
(
[0] => 356
[1] => 405
[2] => 407
[3] => Uses blocks to create their own simple structures and arrangements.
)
[9] => Array
(
[0] => 97
[1] => 155
[2] => 572
[3] =>
)
)
结果,为什么数组中的97值不是排序。 (我认为数组索引[2]按ASC排序)
答案 0 :(得分:1)
你知道订单吗?它是0-9然后是A-Z。因此数组索引[3]按ASC排序。尝试DESC并查看结果。 index [3] [3]位于索引[3]的顶部。