我有一个如下的数组:
Array ( [team1] => Array ( [points] => 10 [players] => Array ( ... ) ) [team2] => Array ( [points] => 23 [players] => Array ( ... ) ) ... many more teams )
我想按照每个队伍的分数排序队伍.我试过这个:
function sort_by_points($a,$b) { if ($a['points']==$b['points']) return 0; return ($a['points']<$b['points'])?1:-1; } usort($this->wordswithdata,"sortbycount");
Array ( [0] => Array ( [points] => 23 [players] => Array ( ... ) ) [1] => Array ( [points] => 10 [players] => Array ( ... ) ) etc... )
有没有办法排序数组而不覆盖团队名称作为数组键?