Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Reference

<xsl:sort> Element

Specifies sort criteria for node lists selected by <xsl:for-each> or <xsl:apply-templates>.

<xsl:sort
  select = string-Expression 
  lang = { nmtoken }
  data-type = { "text" | "number" | QName }
  order = { "ascending" | "descending" }
  case-order = { "upper-first" | "lower-first" }
  /> 

Attributes

select
The sort key for the node. An expression that is evaluated with the specified node as the current node, and with the complete list of nodes being processed in unsorted order as the current node-list. The resulting object is converted to a string that is used as the sort key for that node. The default value of the select attribute is ".". This causes the string-value of the current node to be used as the sort key.
lang
The language alphabet used to determine sort order. If no lang value is specified, the language is determined from the system environment.
data-type
The data type of the strings. The following table list the values allowed for the data-type attribute.

text Specifies that the sort keys should be sorted alphabetically.
number Specifies that the sort keys should be converted to numbers and then sorted according to the numeric value. The sort key is converted to a number.
QName Expanded into a expanded-name. The expanded-name identifies the data type.

If no data type is specified, the type of the expression will be used as the default.

order
The sort order for the strings. The default value is "ascending".
case-order
The order in which to sort strings by capitalization. The default value is "upper-first", which sorts the strings with uppercase letter first.

Element Information

Number of occurrences Unlimited
Parent elements xsl:apply-templates, xsl:for-each
Child elements (No child elements)

Remarks

This sorting algorithm ignores dashes when sorting. This is the "word-sort" method, intended to sort words like "co-op" next to "coop".

For example, the following sort order is produced:

30a-allow
30-allow

Thus the sort treats the items as though they were:

30aallow
30allow

Example

See the example in Sorting XML Using <xsl:sort>.

See Also

Sorting XML Using <xsl:sort>