> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shipstream.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sorting Syntax

When querying collections, the default sort order will typically be by `id` in descending order. However, you can choose
a different sort order by specifying the `sort` query parameter with one of the field names listed in the endpoint
description. You may specify a secondary sort order by specifying the `sort` value as a comma-separated list of the
field names to use for sorting.

Field names prefixed with `-` will be sorted in **descending** order by the given field, otherwise the result will be
sorted in **ascending** order by the given field.

**Example:**

To sort first by `priority` in descending order and then by `name` in ascending order:

```http Request Query theme={null}
?sort=-priority,name
```

The primary key is always applied as an implicit final tiebreaker, so rows with equal sort values have a stable,
deterministic order across requests and pages.

> [!NOTE]
>
> Sorted results are fully pageable. When a collection is sorted by anything other than `id`, the paging cursors
> returned in the `next` and `previous` properties (and in `meta`) are opaque tokens bound to the requested sort —
> follow them as-is and keep the same `sort` value for every page of a walk. Reusing a cursor with a different sort
> returns a `400` error. A plain record `id` is also accepted as a cursor for sorted collections and resumes from that
> record's position in the sort order.

```http Request Query theme={null}
?sort=id&cursor_start=38712
```

See [paging parameters](https://docs.shipstream.io/global-api/paging-parameters.md#paging-sorted-results) for more details on paging sorted
results.

> [!NOTE]
>
> #### Paging
>
> See [paging parameters](https://docs.shipstream.io/global-api/paging-parameters.md) for more information on paging large result sets.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.