+ Start a Discussion

SOQL FOR Loop with ORDER BY clause gives un-ordered list

When SOQL For loops used with ORDER by clause, list gives un-ordered list. We had to store the query in a local variable and loop through it to solve this issue. Any ides why this is happening?
Alain CabonAlain Cabon
Is it a picklist?

[ORDER BY ***fieldOrderByList*** {ASC|DESC} [NULLS {FIRST|LAST}] ]

1) These data types are not supported: multi-select picklist, rich text area, long text area, encrypted (if enabled), and data category group reference (if Salesforce Knowledge is enabled).

2) All other data types are supported, with the following caveats:
2.1) Corporate currency always sorts using corporate currency value, if available.
2.2) 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.
2.3) picklist sorting is defined by the picklist sort determined during setup.

3) The following factors affect results returned with ORDER BY:
3.1) Sorting is case insensitive.
3.2) Sort order is determined by current user locale.