The xsl:perform-sort instruction takes a sequence as its input and produces a sorted sequence as its output.

The input sequence may be specified either using the select attribute, or using the instructions contained within the xsl:perform-sort instruction.

The sort criteria are specified using xsl:sort elements as children of xsl:perform-sort, in the usual way.

For example:

<xsl:perform-sort select="//BOOK">
    <xsl:sort select="author/last-name"/>
    <xsl:sort select="author/first-name"/>

It's often useful to use xsl:perform-sort inside a stylesheet function; the function can return the sorted sequence as its result, and can be invoked directly from an XPath expression.