collections Latest (v1.1.4)

reverse

Reverses the order of the $argument.

reverse(argument: string | array) -> array

Description

Reverses the order of the $argument.

Arguments

Required

Name Type Description
argument string, array

Returns

Type: array

Examples

search(reverse(@), [0,1,2,3,4]) → [4,3,2,1,0]
search(reverse(@), []) → []
search(reverse(@), ["a","b","c",1,2,3]) → [3,2,1,"c","b","a"]
search(reverse(@), "abcd") → "dcba"

Given the following JSON input:


{
  "foo": -1,
  "zero": 0,
  "numbers": [
    -1,
    3,
    4,
    5
  ],
  "array": [
    -1,
    3,
    4,
    5,
    "a",
    "100"
  ],
  "strings": [
    "a",
    "b",
    "c"
  ],
  "decimals": [
    1.01,
    1.2,
    -1.5
  ],
  "str": "Str",
  "false": false,
  "empty_list": [],
  "empty_hash": {},
  "objects": {
    "foo": "bar",
    "bar": "baz"
  },
  "null_key": null
}
Expression Result
reverse(numbers) [5,4,3,-1]
reverse(array) ["100","a",5,4,3,-1]
reverse(empty_list) []
reverse('') ""
reverse('hello world') "dlrow olleh"