- Pages
- /
- Dealers
- /
- Data Depot
- /
- Version 4
- /
- API
- /
- Helpers
- /
- Sorting
- Downloads
- API Documentation
- Support
API News and Updates
Subscribe to stay alert on the API.
Sorting
The sorting helpers allow you to control the arrangement of the response data in a prescribed sequence.
Arrange the API responses in the order that you wish to receive it by sending a sort parameter in your requests.
The parameter syntax structure is: ?sort[direction]=field
.
Pro Tip: [asc] is assumed if direction is left off
The [direction] portion is optional and [asc] is assumed as default if omitted from your request.
For example: ?sort=field
is the same as saying
?sort[asc]=field
Example requests
Sort by name ascending
Get a collection of Attributekeys sorted in alphabetical order by name
.
https://api.wps-inc.com/attributekeys?sort[asc]=name
or
https://api.wps-inc.com/attributekeys?sort=name
Note that both these requests return the same result, sorted in the same way, because [asc] is the default behavior.
Sort by name descending
Get a collection of Attributekeys sorted in reverse-alphabetical order by name
.
https://api.wps-inc.com/attributekeys?sort[desc]=name
Sorting includes
Include all the Items of a specific Product
and sort those Items by list_price
in descending order highest to lowest.
https://api.wps-inc.com/products/187138?include=items:sort(list_price)
As with primary collections, if the sort direction is left off, we'll assume you want asc
order.
You can also explicitly pass a direction by adding a pipe character (|) between the field and the direction.
https://api.wps-inc.com/products/187138?include=items:sort(list_price|desc)