Sort: Record<string, SortDirection | string | number[] | DataAPIVector>

Specifies the sort criteria for selecting documents.

Can use 1/-1 for ascending/descending, or $vector for sorting by vector distance.

See SortDirection for all possible sort values.

NB. The order of the fields in the sort option is significant—fields are sorted in the order they are listed.

Example

// Sort by name in ascending order, then by age in descending order
const sort1: Sort = {
name: 1,
age: -1,
}

// Sort by vector distance
const sort2: Sort = {
$vector: [0.23, 0.38, 0.27, 0.91, 0.21],
}

See

SortDirection