Description
The functx:sort function sorts a sequence of values or nodes. If nodes are provided, their typed values are compared (if they are untyped, they are treated like strings.) Although this can easily be accomplished with an order by clause, calling this function makes the query less verbose because you can avoid writing a FLWOR expression solely to sort the values.
Arguments and Return Type| Name | Type | Description |
$seq |
item()* |
the sequence to sort |
| return value |
item()* |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:sort
( $seq as item()* ) as item()* {
for $item in $seq
order by $item
return $item
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function sort
( $seq as item()* ) as item()* {
for $item in $seq
order by $item
return $item
} |
Exampleslet $in-xml := | <in-xml>
<f>c</f>
<f>a</f>
<e>b</e>
</in-xml> | return |
| XQuery Example | Results |
|---|
functx:sort(('c','a','b'))
|
('a', 'b', 'c')
|
functx:sort($in-xml/*)
|
<f>a</f>
<e>b</e>
<f>c</f>
|
See AlsoHistory |
|