array:sort

Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function, using the supplied collation.

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

Arguments

 

$array

array(*)

The input array

 

$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/array

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 in Saxon-HE from Saxon 10; in Saxon-PE/EE since 9.7. Signature changed to add $collation argument from 9.7.0.8.