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) 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.


Did this page help you?
// Bulk plan CTA banner: requested by Alison to promote the high-volume pricing plan. Injected in Footer HTML per ReadMe convention, but renderd at the top of the viewport via the fixed-position CSS above.
Sending 250K+ links a year? You qualify for a better rate. See high-volume pricing