src/Parameters.php
public function getSort(array $available = [])
    {
        $sort = [];

        if ($input = $this->getInput('sort')) {
            $fields = explode(',', $input);

            foreach ($fields as $field) {
                if (substr($field, 0, 1) === '-') {
                    $field = substr($field, 1);
                    $order = 'desc';
                } else {
                    $order = 'asc';
                }

                $sort[$field] = $order;
            }

            $invalid = array_diff(array_keys($sort), $available);

            if (count($invalid)) {
                throw new InvalidParameterException(
                    'Invalid sort fields ['.implode(',', $invalid).']',
                    3,
                    null,
                    'sort'
                );
            }
        }

        return $sort;
    }
public function getSort(array $available = [])
    {
        $sort = [];

        if ($input = $this->getInput('sort')) {
            $fields = explode(',', $input);

            foreach ($fields as $field) {
                if (substr($field, 0, 1) === '-') {
                    $field = substr($field, 1);
                    $order = 'desc';
                } else {
                    $order = 'asc';
                }

                $sort[$field] = $order;
            }

            $invalid = array_diff(array_keys($sort), $available);

            if (count($invalid)) {
                throw new InvalidParameterException(
                    'Invalid sort fields ['.implode(',', $invalid).']',
                    3,
                    null,
                    'sort'
                );
            }
        }

        return $sort;
    }
public function getSort ( array $ available = [ ] ) { $ sort = [ ] ; if ( $ input = $ this -> getInput ( 'sort' ) ) { $ fields = explode ( ',' , $ input ) ; foreach ( $ fields as $ field ) { if ( substr ( $ field , 0 , 1 ) === '-' ) { $ field = substr ( $ field , 1 ) ; $ order = 'desc' ; } else { $ order = 'asc' ; } $ sort [ $ field ] = $ order ; } $ invalid = array_diff ( array_keys ( $ sort ) , $ available ) ; if ( count ( $ invalid ) ) { throw new InvalidParameterException ( 'Invalid sort fields [' . implode ( ',' , $ invalid ) . ']' , 3 , null , 'sort' ) ; } } return $ sort ; }
Get the sort.

@param array $available

@throws \Tobscure\JsonApi\Exception\InvalidParameterException

@return array
Get the sort .