Sorting

Sort results

Parameters

The sortBy parameter allows to control the sorting of the results with a list of different values (and order for each value). In order to sort by an attribute, it must be defined as a Sortable attribute in the XO Console.

Name

Type

Is Required ?

Default value

sortBy

array of SortValue

βœ–

empty array

sortBy

Sort results by a list of values. Each SortValue must be a JSON object with the following properties:

Property
Type
Description

attribute

string

Name of the value to sort by. Must be defined in the XO Console.

order

'asc' or 'desc'

Order of the results

(ascending / descending)

Notes

  • By default, order is set to 'asc' if not specified

  • SortValue objects are evaluated by order of appearance. ie. The first SortValue takes precedence over the second, etc...

  • The sort order depends on the attribute type: numeric values are sorted in numeric order, strings are sorted in alphanumeric order, dates in chronological order ...

  • If one of the attributes is not registered as a Sortable attribute in the XO Console, an error is returned.

Response

All responses from XO Search uses the same format. Check API Reference page for a more detailed description of this format.

API Referencechevron-right

Usage example

  • Sort results by decreasing price order

NodeJS / NPM example

HTML example

Last updated