Order By Considerations

AVAILABLE API VERSION
API v56.0 and later

orderBy is compatible with relationship queries. For example, you can order by Account.Name like this.

The previous query is similar to the following SOQL statement.

Additionally, the orderBy argument follows these SOQL limitations.

  • The sort order depends on your user locale setting. For English locales, SOQL uses the UTF-8 values of the uppercase character to create a sort order. In other words, sorting for English locales is case insensitive.

  • For non-English locales, SOQL uses a pre-defined order that is natural for the locale specified. This is because different cultures may sort the same characters in different ways, and this nuance can't be captured by the UTF-8 values alone.

By default, the first 10 results are returned with pagination information. You can request for a larger number of results to be returned by using the first argument.

The previous query is similar to the following SOQL ORDER BY clause.