Without sorting instructions, most collections implement a default sorting strategy, as described in the API Reference.

It takes a comma-separated list of keys as values. Each key is generally named with the name of the property the sorting will be applied on, e.g.: id, name, etc…

Sorting direction (i.e. “ascending” vs “descending”) is indicated through adding a prefix to the name of the property the sorting should be applied to:

DirectionPrefixExample
Descending"-" (hyphen)/employees?sort=-familyName: return employees by descending family name.
Ascending"+" (plus) or "" (nothing)/leaves?sort=startsOn: return leaves by ascending start date.

When using the ”+” character, then it must be URL encoded, i.e.: "%2B".

When multiple sorting keys are given, then they are applied in the same order than they are given. For example: /employees?sort=familyName,givenName returns all employees, sorted by ascending family name THEN by ascending given name. In this case, the “Bros” brothers are returned by ascending first name: ‘Luigi (Bros)’, then ‘Mario (Bros)’.

P.S.: Technically, Mario’s and Luigi’s family name should be “Mario”, but it feels wrong for some reason.

Was this page helpful?