src/Search/Search.php
public function setSort($fieldName, $order = 'asc'): self
    {
        if (null !== $fieldName) {
            $sort = [];
            $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order];

            foreach ($fields as $fieldName => $order) {
                $sort[] = [$fieldName => $order];
            }
        } else {
            $sort = null;
        }

        $this->sort = $sort;

        return $this;
    }
public function setSort($fieldName, $order = 'asc'): self
    {
        if (null !== $fieldName) {
            $sort = [];
            $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order];

            foreach ($fields as $fieldName => $order) {
                $sort[] = [$fieldName => $order];
            }
        } else {
            $sort = null;
        }

        $this->sort = $sort;

        return $this;
    }
public function setSort ( $ fieldName , $ order = 'asc' ) : self { if ( null !== $ fieldName ) { $ sort = [ ] ; $ fields = is_array ( $ fieldName ) ? $ fieldName : [ $ fieldName => $ order ] ; foreach ( $ fields as $ fieldName => $ order ) { $ sort [ ] = [ $ fieldName => $ order ] ; } } else { $ sort = null ; } $ this -> sort = $ sort ; return $ this ; }
Sets the sort fields and directions.

@param array|string $fieldName
@param string       $order

@return Search
Sets the sort fields and directions .