---
title: SORT
url: https://www.tines.com/docs/formulas/functions/sort/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# SORT

*[View on tines.com](https://www.tines.com/docs/formulas/functions/sort/)*

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

**Categories:** Arrays

## Syntax

```
SORT(array, path, [include_json_paths: FALSE])
```

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "message": [
      "north",
      "South",
      "east",
      "west"
    ]
  }
}
```

Formula:

```
SORT(my_action.message)
```

Output:

```json
[
  "South",
  "east",
  "north",
  "west"
]
```

### Example 2: Sorts by key

Input:

```json
{
  "animals": [
    {
      "name": "Dog"
    },
    {
      "name": "Cat"
    },
    {
      "name": "Bear"
    }
  ]
}
```

Formula:

```
SORT(animals, 'name')
```

Output:

```json
[
  {
    "name": "Bear"
  },
  {
    "name": "Cat"
  },
  {
    "name": "Dog"
  }
]
```

### Example 3: Sorts by nested key

Input:

```json
{
  "employees": [
    {
      "name": "Jim",
      "address": {
        "city": "New York"
      }
    },
    {
      "name": "John",
      "address": {
        "city": "Dublin"
      }
    },
    {
      "name": "Jane",
      "address": {
        "city": "London"
      }
    }
  ]
}
```

Formula:

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

Output:

```json
[
  {
    "name": "John",
    "address": {
      "city": "Dublin"
    }
  },
  {
    "name": "Jane",
    "address": {
      "city": "London"
    }
  },
  {
    "name": "Jim",
    "address": {
      "city": "New York"
    }
  }
]
```

## Sample actions

```json
{
  "standardLibVersion": "13",
  "actionRuntimeVersion": "1",
  "agents": [
    {
      "disabled": false,
      "name": "SORT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "sorted": "=SORT(my_action.arr1)"
        }
      },
      "position": {
        "x": -6570,
        "y": -1350
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "arr1": [
            "dog",
            "cat",
            "Llama",
            "BEAR",
            "4"
          ]
        }
      },
      "position": {
        "x": -6570,
        "y": -1455
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 0
    }
  ],
  "diagramNotes": []
}
```
