Sorting can be done on the following data types:
long
double
datetime
keyword
Parameters
Parameter | Description | Type | Required | Values |
---|---|---|---|---|
field | Field name to sort by | string | ✓ | - |
order | Sort order direction | string | asc, desc |
Sort order options
Value | Description |
---|---|
asc | Sorts in ascending order |
desc | Sorts in descending order |
Usage
The sort parameter accepts an array of sort objects, allowing multiple field sorting with different orders.Python
Examples
Single field sort
Multiple field sort
When multiple sort fields are specified, the sorting is applied in the order they appear in the array. Documents are first sorted by the first field, then by the second field for documents with the same first field value, and so on.