After a query is defined with the aforementioned query elements, the result is a set of items. The ORDER BY directive orders the results by item properties. For example:

age > 30 ORDER BY firstName

This query returns a result set where items are ordered by the firstName property in ascending order—the default. Results can also be ordered in descending order by adding SORT DESC to the end of the directive:

age > 30 ORDER BY firstName SORT DESC

Results can be ordered by multiple properties. For example:

age > 30 ORDER BY lastName, firstName SORT DESC

This orders results by lastName. If multiple results have the same lastName, within their group they are ordered by firstName in descending order.

A further directive, CASE IGNORECASE, can specify case-insensitive sorting:


Note that you can omit the tokens SORT and CASE, unless you use parameters for the ASC/DESC or USECASE/IGNORECASE tokens.

loading table of contents...