protected function sortList(array &$list, array $allowed, array $query, array $default = array())
    {
        if (empty($default)) {
            $default = array('sort' => '', 'order' => '');
        } else {
            $order = reset($default);
            $field = key($default);
            $default = array('sort' => $field, 'order' => $order);
        }

        $query += $default;

        if (in_array($query['sort'], $allowed)) {
            uasort($list, function ($a, $b) use ($query) {
                return $this->callbackSortList($a, $b, $query);
            });
        }
    }
protected function sortList(array &$list, array $allowed, array $query, array $default = array())
    {
        if (empty($default)) {
            $default = array('sort' => '', 'order' => '');
        } else {
            $order = reset($default);
            $field = key($default);
            $default = array('sort' => $field, 'order' => $order);
        }

        $query += $default;

        if (in_array($query['sort'], $allowed)) {
            uasort($list, function ($a, $b) use ($query) {
                return $this->callbackSortList($a, $b, $query);
            });
        }
    }
protected function sortList ( array & $ list , array $ allowed , array $ query , array $ default = array ( ) ) { if ( empty ( $ default ) ) { $ default = array ( 'sort' => '' , 'order' => '' ) ; } else { $ order = reset ( $ default ) ; $ field = key ( $ default ) ; $ default = array ( 'sort' => $ field , 'order' => $ order ) ; } $ query += $ default ; if ( in_array ( $ query [ 'sort' ] , $ allowed ) ) { uasort ( $ list , function ( $ a , $ b ) use ( $ query ) { return $ this -> callbackSortList ( $ a , $ b , $ query ) ; } ) ; } }
Sort the list by a field
@param array $list
@param array $allowed
@param array $query
@param array $default
Sort the list by a field