php数组排序 问题已解决,谁能帮我优化一下

如下数组按照sort已经排序,按照降序排序 已完成,现在需要如果sort相同的时候,按照time降序再次排序一下,数组如下

$order = [
        [
            'order_sn' => '129381283712',
            'sort' => '102',
            'time' => '1492841339',
        ],
        [
            'order_sn' => '129381283712',
            'sort' => '102',
            'time' => '1492841440',
        ],
        [
            'order_sn' => '129381283712',
            'sort' => '101',
            'time' => '1492841541',
        ],
        [
            'order_sn' => '129381283712',
            'sort' => '101',
            'time' => '1492841642',
        ],
        [
            'order_sn' => '129381283712',
            'sort' => '100',
            'time' => '1492841743',
        ],
        [
            'order_sn' => '129381283712',
            'sort' => '100',
            'time' => '1492841844',
        ]
    ];

谁来帮我解决一下

已解决下面是我的方法

$data = array_chaifen($order);

    $_order = [];
    foreach ($data as $key => $value) {
        foreach ($value as $n => $m) {
            $_order[] = $m;
        }
    }

    foreach ($_order as $key => $value) {
        $_order[$key]['time'] = timeFormat($value['time']);
    }

    p($_order);
function timeFormat($timeInt,$format='Y-m-d'){
        if(empty($timeInt)||!is_numeric($timeInt)||!$timeInt){
            return '';
        }
        $d = (time()-$timeInt);
        if($d<0){
            return '';
        }else{
            if($d<60){
                return $d.'秒前';
            }else{
                if($d<3600){
                    return floor($d/60).'分钟前';
                }else{
                    if($d<86400){
                        return floor($d/3600).'小时前';
                    }else{
                        if($d<604800){//7天内
                            return floor($d/86400).'天前';
                        }else{
                            return date($format,$timeInt);
                        }
                    }
                }
            }
        }
    }


    function array_chaifen ($data)
    {
        $arr = [];
    
        foreach ($data as $k => $v) {
            $arr[$v['sort']][] = $v;
        }

        $ret = [];
        $_data = [];
        foreach ($arr as $key => $value) {
            foreach ($value as $n => $m) {
                $ret[$key][] = $m['time'];
            }
            $_data[] = array_pauxu($ret[$key], $arr[$key]);
        }
        return $_data;
        
    }

    function array_pauxu ($ret, $arr)
    {
        array_multisort($ret, SORT_DESC, $arr);
        return $arr;
    }

谁能帮我优化一下。。。

JellyBool
修改的评论也不能少于六个字哦!
jasester
修改的评论也不能少于六个字哦!