> For the complete documentation index, see [llms.txt](https://docs.fabricplan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fabricplan.com/documentation/plan/planning-sheets/formula-syntax/math-functions/sort.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.fabricplan.com/documentation/plan/planning-sheets/formula-syntax/math-functions/sort.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
