xsl:perform-sort
Sorts a sequence and returns the sorted result, without iterating.
<xsl:perform-sort select="$items">
<xsl:sort select="@price" data-type="number"/>
</xsl:perform-sort>Use xsl:perform-sort when you need a sorted sequence as an XPath value (for example to assign to a variable), rather than to drive an iteration. The input can be supplied via the select attribute or via a sequence constructor body — but xsl:sort children must always come first.
Attributes
| Attribute | Description |
|---|---|
select |
XPath expression for the input sequence. If absent, the body provides the input. |
Examples
Storing a sorted sequence in a variable:
<xsl:variable name="ranked" as="element(item)*">
<xsl:perform-sort select="item">
<xsl:sort select="@score" data-type="number" order="descending"/>
</xsl:perform-sort>
</xsl:variable>Sorting an inline sequence:
<xsl:perform-sort>
<xsl:sort select="." data-type="number"/>
<xsl:sequence select="3, 1, 4, 1, 5, 9, 2, 6"/>
</xsl:perform-sort>