Order By Examples

AVAILABLE API VERSION
API v56.0 and later

Order objects are used to order the result set of records. All sObjects in the schema have a corresponding order type. The order type combines the object API name with the _OrderBy suffix. For example, Account has a corresponding Account_OrderBy type.

Pass in the orderBy argument to the object.

The query returns the following example response.

Here's an example orderBy argument for contacts on account records.

The query returns the following example response.

Custom metadata types (types ending in __mdt) don't support ordering through parent relationships, and so they don't have any input object fields corresponding to parent relationships on the OrderBy object.