# SORT

The *SORT* function accepts a series of values and returns an array of values sorted in ascending order. It is commonly used to arrange numeric data for comparison, ranking, and analytical calculations. Since the function returns an array, individual elements can be accessed using their index positions.

{% hint style="info" %}

#### Note

To sort in descending order use the *SORTDESC* function.
{% endhint %}

#### Syntax

```javascript
SORT(value1, [value2], ...)
```

#### Arguments

* `value1`: The first value to sort.
* `value2, ...` (Optional): Additional values to include in the sorting operation.

#### Return value

Returns an array of values sorted in ascending order.

#### Example

Consider a scenario where quarterly actuals values need to be analyzed to identify the lowest and second-lowest actuals amounts. The SORT function can be used to sort the quarterly actuals values for each row in ascending order.

In this example, the variable a stores the array returned by the SORT function. The lowest quarterly revenue can then be accessed using a\[0], while the highest quarterly revenue can be accessed using a\[3].

#### Excel equivalent

[SORT](https://support.microsoft.com/en-us/office/sort-function-22f63bd0-ccc8-492f-953d-c20e8e44b86c)


---

# 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.fabricplan.com/planning-sheets/formula-syntax/math-functions/sort.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.
