Changes

Jump to navigation Jump to search
735 bytes added ,  12:57, 12 September 2014
Please check out the [[Array Module]] for more details.
 
===fn:sort===
 
; Signatures
* <code>fn:sort($input as item()*) as item()*</code>
* <code>fn:sort($input as item()*, $key as function(item()*) as xs:anyAtomicType*)) as item()*</code>
 
Returns a new sequence with sorted {{Code|$input}} items. If a sort {{Code|$key}} function is given, it will be applied on all items. The items of the resulting values will be sorted using the semantics of the {{Code|lt}} expression.
 
<pre class="brush:xquery">
sort(reverse(1 to 3)) (: yields 1, 2, 3 :),
sort((3, -2, 1), abs#1) (: yields 1, -2, 3 :),
sort((1,2,3), function($x) { -$x }) (: yields 3, 2, 1 :),
sort((1, 'a')) (: yields an error, as strings and integers cannot be compared :)
</pre>
===fn:contains-token===
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu