Skip to content

6.2. Sorting the response

Dane Rossenrode edited this page Apr 9, 2016 · 1 revision

You can use the 'sort' key to sort the list of entities by multiple properties. List every property in a comma-separated string, in the order that you want to sort by. Prefixing the property name with a dash (-) will sort by that property in a descending order; the default is ascending.

Example query:

This will sort by reverse creation date, and return only one result. In other words, it will return the single latest result.

http://mydrupalsite.com/api/v1.0/my-resource-name?sort=-created&range=1

Quick links:

Defining a default sort: https://github.com/RESTful-Drupal/restful/blob/7.x-2.x/docs/plugin.md#defining-a-default-sort

Disabling sort capability: https://github.com/RESTful-Drupal/restful/blob/7.x-2.x/docs/plugin.md#disabling-sort-capability

Clone this wiki locally