reverse
arrayReverses the order of elements in an array
Syntax
reverse(array) Parameters
array (array) The array to reverse
Returns
array A new array with elements in reverse order
Examples
Input:
[1, 2, 3] | reverse Output:
[3, 2, 1] Input:
["a", "b", "c"] | reverse Output:
["c", "b", "a"] The reverse() function reverses the order of elements in an array, returning a new array with the elements in opposite order. The original array is not modified.
Usage
This function is useful when you need to process data in reverse chronological order, reverse sort results, or simply flip the order of elements in a collection.