# Sort array

The **Sort array** node is  used to sort array in either ascending or descending order.

### Properties Panel

#### General

<table data-full-width="false"><thead><tr><th width="244">Field</th><th>Description</th><th>Required</th><th data-hidden>Default</th></tr></thead><tbody><tr><td>Node name</td><td><a href="../../../node-name"><mark style="color:blue;"><strong>Checkout Node name</strong></mark></a></td><td>true</td><td>_</td></tr><tr><td>Variable name</td><td>Variable name to store result</td><td>true</td><td>_</td></tr><tr><td>Array to sort</td><td>Values to sort</td><td>true</td><td></td></tr><tr><td>Key to sort by</td><td>Key to sort array by </td><td>false</td><td></td></tr><tr><td>Sort order</td><td>Ascending or Descending</td><td>false</td><td></td></tr></tbody></table>

### Conditional fields

**Key to sort by :**  This field is required if array to sort have dict/object values. e.g.

```javascript
[
  {
    name: "john",
    age:20
  },
  ...
]
```

If you want to sort this list based of age then you can specify `Key to sort by` as `age` &#x20;

### Returns

This node does not return any values but create a new variables with result . You can access it using magical autocomplete using `$.variables.<Variable name>`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cosmocloud.io/flow-builder/node-types/variable-nodes/arrays/sort-array.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
