order-by Clause: Sort Results

Description

Sorts the returned items.

Applies To

All entity collection resources.

Remarks

Use logical names to identify the fields. See Field Names.

If no order-by clause is sent, the collection is sorted by entity ID.

If an order-by field is a reference field, the reference value is used. For example, in the clause tests?order-by={parent-id[DESC]}, parent-id is a reference to a subject folder. The results are sorted by the value of the referenced item, the subject name, and not by the numeric value of the ID. To change this behavior, set the site administration parameter ENABLE_REFERENCE_FIELD_SORTING to N.

Results can be sorted by any fields of the entity. For example:
tests?order-by={status[ASC];name[DESC]}

The default direction is ASC (ascending), so the following clause is equivalent to the example above:
tests?order-by={status;name[DESC]}

Order by fields in another entity type using aliases. For example:
tests?fields=id,name,test-folder.id,test-folder.name&order-by={test-folder.name[ASC]}

Do not use more than one alias to reference to the same entity. For example,ordering by contains-test-folder.name;test-folder.id, will not result in the intended sort because alias test-folder and alias contains-test-folder both refer to test folders.

For more information about aliases, see Relations.


© 1994 - 2014 Hewlett-Packard Development Company, L.P.