PHP排序函数sort、rsort、asort、arsort、ksort、krsort、array_multisort

1.sort函数用于对数组元素值从低到高排序,去除原始索引元素,重新生成0,1,2..的键
2.rsort函数用于对数组元素值从高到低排序,去除原始索引元素,重新生成0,1,2..的键
3.asort函数用于对数组元素值从低到高排序,保持索引关系
4.arsort函数用于对数组元素值从高到低排序,保持索引关系
5.ksort函数用于对数组索引值从低到高排序
6.krsort函数用于对数组索引值从高到低排序

二维数组按某字段排序

array_multisort(array_column($data, 'sort'), SORT_DESC, $data);

  

原文地址:https://www.cnblogs.com/caohongchang/p/11346029.html