array:reverse

Returns an array containing all the members of a supplied array, but in reverse order.

Signature

array:reverse($array as array(*)) as array(*)

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

The function returns the result of the expression: array:join( fn:reverse(1 to array:size($array)) ! [$array(.)] )

Examples

The expression array:reverse(["a", "b", "c", "d"]) returns ["d", "c", "b", "a"].

The expression array:reverse([("a", "b"), ("c", "d")]) returns [("c", "d"), ("a", "b")].

The expression array:reverse([(1 to 5)]) returns [(1, 2, 3, 4, 5)].

The expression array:reverse([]) returns [].