时间:2021-07-01 10:21:17 帮助过:3人阅读
foreach($data as $key=>$value){ $win[$key] = $value['win']; $lose[$key] = $value['lose'];}array_multisort($win,SORT_ASC,$lose,SORT_DESC,$data);var_dump($data);
$data[] = array('win' => 67, 'lose' => 2);$data[] = array('win' => 86, 'lose' => 1);$data[] = array('win' => 85, 'lose' => 6);$data[] = array('win' => 98, 'lose' => 2);$data[] = array('win' => 86, 'lose' => 6);$data[] = array('win' => 67, 'lose' => 7);
无论用什么方法,都需要对每个排序键进行处理
预处理的 foreach 实际是在对排序键做索引
multisort参数继续列下去就是
但是,实际应用时,如果数据不多,基本是三列排序就决定了,第四项之后对顺序影响很微的