SORT_NATURAL

Sorts elements in an array by a property of an element in the array (case-insensitive). Pass a dot-separated path to sort by nested keys.

Syntax 

SORT_NATURAL(array, path, [include_json_paths: FALSE])

Usage examples 

Example 1

Input

1
{
2
"my_action": {
3
"message": [
4
"north",
5
"South",
6
"east",
7
"west"
8
]
9
}
10
}

Formula

SORT_NATURAL(my_action.message)

Output

1
[
2
"east",
3
"north",
4
"South",
5
"west"
6
]

Example 2

Sorts by key

Input

1
{
2
"animals": [
3
{
4
"name": "dog"
5
},
6
{
7
"name": "Cat"
8
},
9
{
10
"name": "bear"
11
}
12
]
13
}

Formula

SORT(animals, 'name')

Output

1
[
2
{
3
"name": "bear"
4
},
5
{
6
"name": "Cat"
7
},
8
{
9
"name": "dog"
10
}
11
]

Example 3

Sorts by nested key

Input

1
{
2
"employees": [
3
{
4
"name": "Jim",
5
"address": {
6
"city": "new york"
7
}
8
},
9
{
10
"name": "John",
11
"address": {
12
"city": "dublin"
13
}
14
},
15
{
16
"name": "Jane",
17
"address": {
18
"city": "London"
19
}
20
}
21
]
22
}

Formula

SORT(employees, 'address.city', include_json_paths: TRUE)

Output

1
[
2
{
3
"name": "John",
4
"address": {
5
"city": "dublin"
6
}
7
},
8
{
9
"name": "Jane",
10
"address": {
11
"city": "London"
12
}
13
},
14
{
15
"name": "Jim",
16
"address": {
17
"city": "new York"
18
}
19
}
20
]

Sample Actions 

Transform
SORT NATURAL
Transform
My Action

Select an action to inspect

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?