The following table lists the limits for sorting data (unless otherwise specified).

Table 1. Sorting limits
Category Limit
Levels 1 to 16 columns or expressions.
Size When executing a query with a sort (BY clause), there is a size limit on the number of sort bytes the query can handle. The number of sort bytes is the number of bytes contained in all the indexes that are involved in the query for a single result-list entry. This limit is roughly 1970 bytes. The exact size limit depends on the number of columns and expressions involved in the sort.

Example of size limitation

define temp-table tt
  field f1 as character
  field f2 as character
  index idx1 f1 f2.

create tt.
f1 = fill("1",985).
f2 = fill("2",984).  /* works as is, but increasing to 985 
                        results in max key size error */

for each tt by f1 by f2:

end.