---
updatedAt: 2025-11-12T02:16:43.000Z
agentTools:
  projectIndex: https://developers.rebrandly.com/llms.txt
---

# Sorting collections

A collection of resources can be sorted (either descending or ascending) according to a given criteria.

## Sorting criteria

Sorting criteria is the sorting mode to be applied on a collection *before* pagination (see [Understanding Pagination](https://developers.rebrandly.com/docs/understanding-pagination)) applies.

Every resource collection management endpoint comes with an `orderBy` parameter used to define which sorting criteria has to be applied.

Examples of an `orderBy` parameter's possible values are: `createdAt` (to sort by creation datetime), `updatedAt` (to sort by last update date/time) and so on.

## Sorting direction

Sorting direction is the direction, according to sorting criteria, to be applied on a collection *before* pagination applies. The only two possible directions are "ascending" (from first to last) and "descending" (from last to first).

Every resource collection management endpoint comes with an `orderDir` parameter used to define which sorting direction has to be applied.\
Possible values for `orderDir` are `asc` (ascending) and `desc` (descending).

## Combining sorting criteria

To exploit the full power of sorting criteria, it is possible to combine two sorting criteria together:

*First, sort by descending X, then sort by ascending Y if X subsequent X values are equal*,\
can be obtained by assigning `orderBy` parameter value `X,Y` and by assigning `orderDir` parameter value `desc,asc`.