Skip to content
Logan Serman edited this page Jan 14, 2015 · 1 revision

APIs accept a sort parameter to order the results by a field on the requested resource. To change the direction, asc or desc can be passed via the direction parameter, which defaults to asc.

GET http://*.*/api/posts?sort=title
# => { "posts": [{ "id": 1, "author": 1, title: 'ABC' }, { "id": 2, "author": 1, title: 'BCD' }] }

GET http://*.*/api/posts?sort=title&direction=desc
# => { "posts": [{ "id": 2, "author": 1, title: 'BCD' }, { "id": 1, "author": 1, title: 'ABC' }] }
Clone this wiki locally