Description
The functx:sort-as-numeric function sorts a sequence of numeric values or nodes. This is useful for untyped values, because the order by clause by default treats values as strings, and would therefore sort 100 before 99.
Arguments and Return TypeName | Type | Description |
$seq |
item()* |
the sequence to sort |
return value |
item()* |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:sort-as-numeric" as="item()*"
xmlns:functx="http://www.functx.com">
<xsl:param name="seq" as="item()*"/>
<xsl:for-each select="$seq">
<xsl:sort select="number(.)"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <in-xml>
<f>1</f>
<f>35</f>
<e>4</e>
</in-xml> |
| </xsl:variable> |
XPath Example | Results |
---|
functx:sort-as-numeric(('1','100','99')) |
('1', '99', '100') |
functx:sort-as-numeric($in-xml/*) |
<f>1</f>
<e>4</e>
<f>35</f> |
See AlsoHistory |
Recommended Reading:
|