Ordering Collections ($orderby)

The value of the $orderby parameter contains a comma-separated list of property names to sort by.

The property name MAY include the suffix “asc” for ascending or “desc” for descending order, separated from the property name by one or more spaces.

If “asc” or “desc” is not specified, the service MUST order by the specified property in ascending order.

The following table contains some common use cases of $orderby parameter

Query Description

Example

Get accounts ordered by created date

/api/accounts$orderby=createdAt

Get accounts ordered by created date in descending order

/api/accounts$orderby=createdAt desc

Get products ordered by last update date in descending order

/api/products$orderby=updatedAt desc

Get contacts order by account name, then last name and first name

/api/contacts$orderBy=accountname,lastname,firstname

Get contacts order by account name in descending order, then last name and first name

/api/contacts$orderBy=accountname desc,lastname,firstname