我有一个数组,当我运行print_r($array)
时,我得到:
Array
(
[XS] => 110
[S] => 171
[M] => 172
[L] => 171
[XL] => 171
[2X] => 172
[3X] => 154
[4X] => 139
[5X] => 47
[6X] => 32
[OSFA] => 12
[FITTED S-M] => 12
[FITTED L-XL] => 12
[ADJ] => 52
[YXS] => 15
[YSM] => 20
[YMD] => 20
[YLG] => 20
[YXL] => 17
[TLG] => 1
[TXL] => 1
[T2X] => 1
[T3X] => 3
[S-M FLEX] => 3
[M-L FLEX] => 3
[L-XL FLEX] => 3
[CHILD STRETCH] => 1
[S/M] => 1
)
我想将它降序排序,但是arsort
返回1.我可以用for循环对它进行排序,但我想要最好的解决方案。有什么建议吗?
答案 0 :(得分:2)
使用arsort($icon,SORT_NUMERIC)
;
您可以将数据排序为数字,将数据放在$ icon