When you fetch a collection of resources, you can request a specific sort for the results, using the sort query parameter.
The value of the sort parameter must be a comma-separated list of fields. Pay attention to avoid whitespaces before or after each comma.
The sort order for each field is ascending unless prefixed with a - (minus) in which case it's descending.
Sortable fields
Not all resource attributes can be used as sorting parameters. You can get the full list of the sortable attributes from the documentation of each resource in the "List all" section (e.g. ).
Please note that if you try to sort a collection of resources by a non-sortable attribute the API which will respond with a 400 Bad Request status code, due to invalid sort criteria.
Examples
Sorting the parent resource by one of its attribute
The following request fetches a collection of SKUs sorted alphabetically by their code:
On success, the API responds with a 200 OK status code, returning a paginated collection of the related resource objects, sorted in the requested order:
You can get the full list of sortable attributes from the documentation of each resource.
The relationship must be one of the sortable relationships for the parent resource (in the example above the shipping category is one of the SKU's relationships), the attribute must be one of the filterable ones for the related resource (in the example above the name is one of the shipping category's attributes).