Changes

Jump to navigation Jump to search
45 bytes added ,  13:56, 11 October 2016
==fn:sort==
{{Mark|Updated with Version 8.6:}}: Collation argument was inserted between first and second argument.
; Signatures
* <code>fn:sort($input as item()*, $collation as xs:string?, $key as function(item()*) as xs:anyAtomicType*)) as item()*</code>
Returns a new sequence with sorted {{Code|$input}} items, using an optional {{Code|$collation}}. If a sort {{Code|$key}} function is givensupplied, 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 :),
reverse(sort(1 to 3)) (: returns the sorted order in descending order :),
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>
;Version 8.6
* Updated: Collation argument was inserted between first and second argument.
;Version 8.4
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu