@coveo/headless
    Preparing search index...

    Interface Sort

    The Sort controller manages how the results are sorted.

    Example: sort.fn.tsx

    interface Sort {
        state: SortState;
        isSortedBy(criterion: SortCriterion | SortCriterion[]): boolean;
        sortBy(criterion: SortCriterion | SortCriterion[]): void;
        subscribe(listener: () => void): Unsubscribe;
    }

    Hierarchy (View Summary)

    Index

    Methods

    Properties

    Methods

    • Verifies whether the specified sort criterion is the currently active one.

      Parameters

      • criterion: SortCriterion | SortCriterion[]

        The sort criterion to evaluate. Can be a single criterion or an array of criteria. The criteria in an array will be applied sequentially. For example, if there's a tie on the 1st criterion, the API uses the 2nd criterion to break the tie. However, this only works when combining: SortByRelevancy followed by one or more SortByField or SortByDate criteria. SortByQRE followed by one or more SortByField or SortByDate criteria. Two or more SortByField criteria. A single SortByDate criterion and one or more SortByField criteria in any order.

        Examples:

        • SortByRelevancy, SortByField
        • SortByQRE, SortByField
        • SortByDate, SortByField, SortByField

      Returns boolean

      true if the specified sort criterion is the currently active one; false otherwise.

    Properties

    state: SortState

    A scoped and simplified part of the headless state that is relevant to the Sort controller.