---
schema_version: "1"
id: 14aa4dc47543fe703ebbb2f10a129ba85fd2347384c18e6d24522a6cd355bb37
title: Order Results
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/order.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/order.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 79e916d3c3f395d084b1619a206d77884faba436db56f84bf70fa7961fec4290
products:
  - GraphQL API
---
# Order Results

| 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.

## Query Sortable Fields

Fields that have a scalar or Field Value Type that support ordering have a corresponding Input Object Field of type `OrderByClause`. The following field types support ordering.

- Int
- String
- Boolean
- Id
- DateTime
- Time
- Date
- TextArea
- PhoneNumber
- Email
- Url
- Currency
- Geolocation
- Longitude
- Latitude
- Picklist
- Long
- Double
- Percent
- Base64

Consider these guidelines for specific field types.

- Corporate currency always sorts using corporate currency value, if available.
- Phone data does not include any special formatting when sorting, for example, non-numeric characters such as dash or parentheses are included in the sorting.
- Picklist sorting is defined by the picklist sort determined during setup.

These data types are not supported.

- Multi-select picklist
- Rich text area
- Long text area
- Encrypted
- Data category group reference, if Salesforce Knowledge is enabled

To identify sortable fields on an object, query the [objectInfos type](https://developer.salesforce.com/docs/platform/graphql/guide/query/query-objectinfo.md).

```
query objectInfos {
  uiapi {
    objectInfos(apiNames: ["Account"]) {
      fields {
        ApiName
        sortable
        compound
      }
    }
  }
}
```

Not all sortable fields can be ordered. Not all fields returned by `objectInfos` are sortable. For example, Address compound fields aren't sortable.

To sort using compound fields, use its constituent fields.
For example, BillingLatitude and BillingLongitude are constituent fields of the BillingAddress compound field.

## Use the `orderBy` Argument

Multiple column sorting is supported by listing more than one field on the `orderBy` argument.

The order of results isn't guaranteed unless you use the `orderBy` argument in a query. When you use `orderBy`, the order of results can vary if there are duplicate values on the fields you use in the `orderBy` argument.

For example, if there are multiple account records assigned to the same industry, the order of the results can vary. To ensure that the order of the results is consistent, add the Id to the `orderBy` argument.

```
query IndustryOrderBy {
  uiapi {
    query {
      Account ( orderBy: { Industry: { order: ASC }, Id: { order: ASC } }) {
        edges {
          node {
            Name { value }
            Industry { value }
          }
        }
      }
    }
  }
}
```

The previous query is similar to the following SOQL statement.

```
SELECT Name, Industry
FROM Account
ORDER BY Industry, Id
```

The following example returns Account records in alphabetical order by first name, sorted in descending order, with accounts that have null names appearing last.

```
query IndustryOrderByNulls {
  uiapi {
    query {
      Account ( orderBy: { Name: { order: DESC, nulls: LAST }}) {
        edges {
          node {
            Name { value }
          }
        }
      }
    }
  }
}
```

The previous query is similar to the following SOQL statement.

```
SELECT Name
FROM Account
ORDER BY Name DESC NULLS LAST
```

## See Also

[SOQL and SOSL Reference: `ORDER BY` statement](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_orderby.htm)
