public function sort($index, $direction)
    {
        if (!in_array($direction, ['ASC', 'DESC'])) {
            throw new CollectionException('Sort direction must be ASC or DESC.');
        }

        $this->_sort = ['index' => $index, 'dir' => $direction];
        return $this;
    }
public function sort($index, $direction)
    {
        if (!in_array($direction, ['ASC', 'DESC'])) {
            throw new CollectionException('Sort direction must be ASC or DESC.');
        }

        $this->_sort = ['index' => $index, 'dir' => $direction];
        return $this;
    }
public function sort ( $ index , $ direction ) { if ( ! in_array ( $ direction , [ 'ASC' , 'DESC' ] ) ) { throw new CollectionException ( 'Sort direction must be ASC or DESC.' ) ; } $ this -> _sort = [ 'index' => $ index , 'dir' => $ direction ] ; return $ this ; }
Sets sort configuration

@param string $index
@param string $direction
@return $this
@throws CollectionException
Sets sort configuration