> For the complete documentation index, see [llms.txt](https://enable-advisory-1.gitbook.io/the-way-we-work/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enable-advisory-1.gitbook.io/the-way-we-work/microsoft-excel/sort.md).

# SORT

**Syntax:**

\=SORT(array, \[sort\_index], \[sort\_order], \[by\_col])

**Explanation:**

* *array* - Range or array to sort.
* *sort\_index* - \[optional] Column index to use for sorting. Default is 1.
* *sort\_order* - \[optional] 1 = Ascending, -1 = Descending. Default is ascending order.
* *by\_col* - \[optional] TRUE = sort by column. FALSE = sort by row. Default is FALSE.

**Example:**

<figure><img src="https://1421118769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdtjvomCsvuXz1wFFAA%2Fuploads%2FhgrI4kq8ZaT2nOjb06dp%2Fimage.png?alt=media&amp;token=1fcfb1f5-8748-42a4-a766-e643def4f7dd" alt=""><figcaption></figcaption></figure>

**Notes:**

The SORT function sorts the contents of a range or array in ascending or descending order with a formula. The result from SORT is a dynamic array of values that will "spill" onto the worksheet into a range. If values in the source data change, the result from SORT will update automatically.
