public function sort($by, $direction = "asc", $override = false) {
        $this->assertInitiated("sort");
        if ($override) {
            $this->query['sort'] = [];
        }
        $this->query['sort'][] = [$by => $direction];
        return $this;
    }
public function sort($by, $direction = "asc", $override = false) {
        $this->assertInitiated("sort");
        if ($override) {
            $this->query['sort'] = [];
        }
        $this->query['sort'][] = [$by => $direction];
        return $this;
    }
public function sort ( $ by , $ direction = "asc" , $ override = false ) { $ this -> assertInitiated ( "sort" ) ; if ( $ override ) { $ this -> query [ 'sort' ] = [ ] ; } $ this -> query [ 'sort' ] [ ] = [ $ by => $ direction ] ; return $ this ; }
Adds a sort clause to the query

@param string $by the key to sort by it
@param string|array $direction the direction of the sort.
Can be an array for extra sort control.
@param boolean $override false by default. if true it will reset the sort
first, then add the new sort entry.
@return QueryBuilder|static|self
Adds a sort clause to the query