Name
<xsl:sort>
Synopsis
<xsl:sort select = "expression" [data-type = “text|number"] [lang = "langcode“] [order = “ascending|descending"] [case-order = “upper-first|lower-first"]/>
The xsl:sort instruction appears as a
child of either xsl:apply-templates or
xsl:for-each. It changes the order
of the context node list from document order to some other
order, such as alphabetic. Multiple-key sorts (for example,
sort by last name, then by first name, then by middle name) can
be performed with multiple xsl:sort
elements in descending order of importance of the keys. The
following attributes are defined:
-
select This contains the key to sort by.
-
data-type By default, sorting is purely alphabetic. However, alphabetic sorting leads to strange results with numbers. For instance, 10, 100, and 1000 all sort before 2, 3, and 4. You can specify numeric sorting by setting the
data-typeattribute tonumber.-
lang Sorting is language dependent. The language can be adjusted by setting the
langattribute to an RFC 1766 language code. The default language is system dependent.-
order This specifies the order by which strings are sorted. The value can be either
descendingorascending. The default isascending.-
case-order The
case-orderattribute can be set toupper-firstorlower-firstto specify whether uppercase letters sort before lowercase letters or vice versa. The default depends on the language.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access