fn:sort

Sorts a supplied sequence, based on the value of a sort key supplied as a function, using the supplied collation. Calling the single-argument version of the function is equivalent to calling the 3-argument form with fn:default-collation() as the second argument and fn:data#1 as the third argument: that is, it sorts a sequence of items according to the typed value of the items.

sort($input as item()*, $collation as xs:string?:=fn:default-collation(), $key as fn(item()) as xs:anyAtomicType*:=fn:data#1) ➔ item()*

Arguments

 

$input

item()*

The input sequence to be sorted

 

$collation

xs:string?

:= fn:default-collation()

The collation used for comparing strings

 

$key

fn(item()) as xs:anyAtomicType*

:= fn:data#1

The sort key

Result

item()*

Namespace

http://www.w3.org/2005/xpath-functions

Links to W3C specifications

XPath 3.1 Functions and Operators

XPath 4.0 Functions and Operators

Saxon availability

Available in XPath 3.1, XSLT 3.0, XQuery 3.1, and later versions. From Saxon 10, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.7. Available for all platforms.

Notes on the Saxon implementation

Available since Saxon 9.7. Signature changed to add $collation argument from 9.7.0.8.