JSON API Sorting
allows you to sort the results produced by your API according to one
by passing one or more criteria to your request using the sort
parameter.
Before continuing please note that the default sort order for each field is ascending
UNLESS the field is prefixed with a hyphen (-
) in which case the sort order will
be descending.
To sort by a single field using ascending order:
/currencies?sort=code
To sort descending:
/currencies?sort=-code
To sort by multiple fields simply pass comma-separated sort fields in the order you want them applied:
/currencies?sort=code,name
/currencies?sort=-code,name
/currencies?sort=-code,-name
/currencies?sort=name,code
CrudJsonApi supports any combination of the above sorts. E.g.
/currencies?include=countries&sort=name,countries.code
/currencies?include=countries&sort=name,-countries.code