Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The
order
attribute specifies whether the order is ascending or descending. Descending order will produce the opposite result of ascending order. This means, for example, that NaN values will appear last rather than first, and also that the effect of the
case-order
attribute is reversed: If you specify
case-order=“upper-first”
with
order=“descending”
, then
drall
will come before
Drall
.
The final sorted order of the items determines the sequence in which they are processed by the containing
position()
will reflect the position of the current item in the sorted sequence.
Collations
When the sort key values to be compared are strings, they are compared using a collation. A collation is essentially a mechanism for deciding whether two strings such as
polish
and
Polish
are considered equal, and if not, which of them should come first.
Choosing the right collation depends on the data that you are sorting, and on the expectations of the users. These expectations vary by country (in Germany, in most modern publications,
ä
is sorted along with
a
, but in Sweden, it is sorted after
z
) and also vary according to the application. Telephone directories, dictionaries, gazetteers, and back-of-book indexes each have their own rules.