Define ordering expression and sort direction.
The following construct(s) refer to this construct:
A SortSpecList
defines one or more sort criteria along with
the direction of ordering, separated by commas. Each SortSpecList
consists of an ordering expression that is optionally followed by one of the
keywords ascending
or descending
. If you omit the
ordering direction, ascending
is taken as default. You can provide
optional collation information introduced by the keyword collation
and an appropriate string literal. The first SortSpecList
acts as
the primary sort criterion, further SortSpecList
s as secondary
criterion etc.
See SortExpr
for examples.
List book titles with their year of publication, newest first:
for $a in input()/bib/book order by $a/@year descending return ($a/@year, $a/title)
List book titles sorted according to French collation:
for $a in input()/bib/book order by $a/title ascending collation "collation?language=fr" return $a/title
Since ascending is the default order modifier, the order
by
clause could also read:
order by $a/title collation "collation?language=fr"
See also SortExpr for examples.