基于array_multisort()函数
//测试数据
$data = [
[
"stu_id"=> 1,
"number"=> "20171114000001",
"join_at"=> "2017-11-14 12:36:16"
],
[
"stu_id"=> 2,
"number"=> "20171114000002",
"join_at"=> "2017-11-14 12:36:16"
],
[
"stu_id"=> 3,
"number"=> "20171114000003",
"join_at"=> "2017-11-14 13:36:14"
],
[
"stu_id"=> 4,
"number"=> "20171114000004",
"join_at"=> "2017-11-14 14:26:15"
],
];
//排序
foreach ($data as $key => $value) {
//将需要排序的值提取出来作为一个数组
$join_at[$key] = $value['join_at'];
$number[$key] = $value['number'];
}
//根据join_at降序,number升序排序
array_multisort($join_at, SORT_DESC, $number, SORT_ASC, $data);
echo $data;
//排序结果
[
{
"stu_id": 4,
"number": "20171114000004",
"join_at": "2017-11-14 14:26:15"
},
{
"stu_id": 3,
"number": "20171114000003",
"join_at": "2017-11-14 13:36:14"
},
{
"stu_id": 1,
"number": "20171114000001",
"join_at": "2017-11-14 12:36:16"
},
{
"stu_id": 2,
"number": "20171114000002",
"join_at": "2017-11-14 12:36:16"
}
]