Name
<xsl:sort>
Synopsis
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-type
attribute tonumber
.-
lang
Sorting is language dependent. The language can be adjusted by setting the
lang
attribute 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
descending
orascending
. The default isascending
.-
case-order
The
case-order
attribute can be set toupper-first
orlower-first
to specify whether uppercase letters sort before lowercase letters or vice versa. The default depends on the language.<xsl:sort select = "
expression
" [data-type = "text|number"] [lang = "langcode
"] [order = "ascending|descending"] [case-order = "upper-first|lower-first"]/>
Get Webmaster in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.