Adldap\Query\Builder::sortBy PHP Method

sortBy() public method

Sorts the LDAP search results by the specified field and direction.
public sortBy ( string $field, string $direction = 'asc', integer | null $flags = null ) : Builder
$field string
$direction string
$flags integer | null
return Builder
    public function sortBy($field, $direction = 'asc', $flags = null)
    {
        $this->sortByField = $field;
        // Lowercase direction for comparisons.
        $direction = strtolower($direction);
        if ($direction === 'asc' || $direction === 'desc') {
            $this->sortByDirection = $direction;
        }
        if (is_null($flags)) {
            $flags = SORT_NATURAL + SORT_FLAG_CASE;
        }
        $this->sortByFlags = $flags;
        return $this;
    }