To sort records, SurrealDB allows ordering on multiple fields and nested fields. Use the ORDER clause to specify a comma-separated list of field names that should be used to order the resulting records.
While not necessary to parse, the ORDER clause can be followed with BY to make queries more readable.
The ASC and DESC keywords can be used to specify whether results should be sorted in an ascending or descending manner. The COLLATE keyword can be used to use Unicode collation when ordering text in string values, ensuring that different cases, and different languages are sorted in a consistent manner. Finally, the NUMERIC can be used to correctly sort text which contains numeric values.
It is also worth noting that COLLATE can be used to order by lexical instead of unicode order. For example, 'á' comes after 'z' by default (Unicode sorting) but with COLLATE 'á' comes before 'z'.