Use the
orderby request parameter to specify sort criteria for one attribute in a list of resources returned by a collection query. The
orderby parameter works like an SQL Order By clause. You can specify one of these sort orders for the attribute:
asc: (Default) Sorts the response data in ascending order.
desc: Sorts the response data in descending order.
Append the sort order to an attribute using an HTML space. For example:%20asc or
%20desc.
If the request succeeds, it returns a
200 OK HTTP status code with requested resource information in the response body. If it does not succeed, it returns a
4nn or
5nn HTTP status code and a message entity.
Syntax
As the first parameter on the request URI:
?orderby=<orderby_expr>
As a subsequent parameter on the request URI:
&orderby=<orderby_expr>
where
<orderby_expr> is defined by the following syntax using Backus-Naur Form (BNF):
prop_expr is an attribute name defined for the resource being queried. Its type can be
int,
float,
string,
InetSocketAddress,
Date,
Boolean,
Enum, or a list whose element is among the above types.
'ASC'/'DESC' is case insensitive.
If a sort order is not specified, the default value is
'ASC'.
NOTE You can use dot notation syntax (resource_type.attribute) in an
orderby expression to sort responses by the value of an attributes from related a resource type. A related resource type is a resource type that is either referred to explicitly in the definition of the target resource type or embedded in the target resource type.
Example 1: Sorting drive information by drive name
The following request retrieves drive names and sizes, and sorts this information by name in ascending order.