src/Services/DocumentSearch.php
private function set_sorting()
    {
        if (isset($this->arrSearch['sorting'])) {
            if (!is_array($this->arrSearch['sorting']) ||
                !in_array($this->arrSearch['sorting']['type'], ['score', 'time']) ||
                !in_array($this->arrSearch['sorting']['order'], ['ascending', 'descending'])
            ) {
                throw new DocumentSearchWrongSorting(
                    '"sorting" key must be an array with keys "type" = "score|time" & "order" = "ascending|descending" '
                );
            }

            if ($this->arrSearch['sorting']['type'] === 'time') {
                $this->arrSearch['sorting']['field'] = 'recs-publishtime';
            }

            $this->arrPayload['sort'][] = $this->arrSearch['sorting'];
        }

        return $this;
    }
private function set_sorting()
    {
        if (isset($this->arrSearch['sorting'])) {
            if (!is_array($this->arrSearch['sorting']) ||
                !in_array($this->arrSearch['sorting']['type'], ['score', 'time']) ||
                !in_array($this->arrSearch['sorting']['order'], ['ascending', 'descending'])
            ) {
                throw new DocumentSearchWrongSorting(
                    '"sorting" key must be an array with keys "type" = "score|time" & "order" = "ascending|descending" '
                );
            }

            if ($this->arrSearch['sorting']['type'] === 'time') {
                $this->arrSearch['sorting']['field'] = 'recs-publishtime';
            }

            $this->arrPayload['sort'][] = $this->arrSearch['sorting'];
        }

        return $this;
    }
Set sorting

@return $this
@throws DocumentSearchWrongSorting