---
title: "SORT function in Excel: syntax and examples | PracticeExcel"
description: "How to use SORT in Excel 365 and Google Sheets: a sorted copy of your data that updates by itself, by any column, up or down."
canonical_url: "https://practiceexcelonline.com/functions/sort"
locale: en
meta:
  "og:description": "How to use SORT in Excel 365 and Google Sheets: a sorted copy of your data that updates by itself, by any column, up or down."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U09SVCBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBTT1JUIGluIEV4Y2VsIDM2NSBhbmQgR29vZ2xlIFNoZWV0czogYSBzb3J0ZWQgY29weSBvZiB5b3VyIGRhdGEgdGhhdCB1cGRhdGVzIGJ5IGl0c2VsZiwgYnkgYW55IGNvbHVtbiwgdXAgb3IgZG93bi4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U09SVChhcnJheSwgW3NvcnRfaW5kZXhdLCBbc29ydF9vcmRlcl0sIFtieV9jb2xdKQ%2Cp_Ii9mdW5jdGlvbnMvc29ydCI%2Cs_4kquZomZ-lVQ-fsu.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "SORT function in Excel: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U09SVCBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBTT1JUIGluIEV4Y2VsIDM2NSBhbmQgR29vZ2xlIFNoZWV0czogYSBzb3J0ZWQgY29weSBvZiB5b3VyIGRhdGEgdGhhdCB1cGRhdGVzIGJ5IGl0c2VsZiwgYnkgYW55IGNvbHVtbiwgdXAgb3IgZG93bi4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U09SVChhcnJheSwgW3NvcnRfaW5kZXhdLCBbc29ydF9vcmRlcl0sIFtieV9jb2xdKQ%2Cp_Ii9mdW5jdGlvbnMvc29ydCI%2Cs_4kquZomZ-lVQ-fsu.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **The SORT function**

Sorts the rows of a range by one of its columns and spills the sorted copy into the cells below. The original data stays as it is.

=

SORT(

## **Syntax**

```
SORT(array, [sort_index], [sort_order], [by_col])
```

<dl><dt>**array **</dt>
<dd>The range to sort.</dd>
<dt>**sort_index **(optional)</dt>
<dd>Which column of the range to sort by, counted from 1. Left out, the first column.</dd>
<dt>**sort_order **(optional)</dt>
<dd>1 or left out for smallest to largest (A to Z), -1 for largest to smallest.</dd>
<dt>**by_col **(optional)</dt>
<dd>TRUE to sort the columns of the range instead of its rows.</dd></dl>

## **Examples**

D1=SORT(A2:B5)

|  | A | B | C | D | E |
| --- | --- | --- | --- | --- | --- |
| 1 | Name | Sales |  | **Ava** | **275** |
| 2 | Maya | 320 |  | **Ben** | **450** |
| 3 | Ben | 450 |  | **Maya** | **320** |
| 4 | Zoe | 180 |  | **Zoe** | **180** |
| 5 | Ava | 275 |  |  | |

D1`=SORT(<sup>1</sup>A2:B5,<sup>2</sup>2,<sup>3</sup>-1)`

|  | A | B | C | D | E |
| --- | --- | --- | --- | --- | --- |
| 1 | Name | Sales |  | **Ben** | **450** |
| 2 | Maya | 320 |  | **Maya** | **320** |
| 3 | Ben | 450 |  | **Ava** | **275** |
| 4 | Zoe | 180 |  | **Zoe** | **180** |
| 5 | Ava | 275 |  |  | |

**In plain words:** Sort <sup>1</sup>the names and sales in A2:B5 by <sup>2</sup>the second column, <sup>3</sup>largest first.

D1=SORT(B2:B5)

|  | A | B | C | D |
| --- | --- | --- | --- | --- |
| 1 | Name | Sales |  | **180** |
| 2 | Maya | 320 |  | **275** |
| 3 | Ben | 450 |  | **320** |
| 4 | Zoe | 180 |  | **450** |
| 5 | Ava | 275 |  | |

## **Practice SORT**

- [**1****Sort a table by sales with SORT**→](https://practiceexcelonline.com/practice/sort-and-unique/sort-function)
- [**2****A sorted list without duplicates**→](https://practiceexcelonline.com/practice/sort-and-unique/sort-unique-list)
- [**3****A drop-down source without repeats**→](https://practiceexcelonline.com/practice/data-validation/drop-down-source-without-repeats)

## **Read the guide**

- [**How to create a drop-down list in Excel, and make it update itself**](https://practiceexcelonline.com/learn/drop-down-list-excel)
- [**How to make a graph in Excel: column, line and pie charts step by step**](https://practiceexcelonline.com/learn/excel-charts)

## **Questions**

<details>

<summary>

### Why does SORT return

</summary>

The sorted result needs empty cells to spill into, and something is in the way. Clear the cells below and to the right of the formula.

</details>

<details>

<summary>

### Does SORT work the same way in Google Sheets?

</summary>

Google Sheets has SORT too, but its arguments differ. You give the column to sort by and TRUE or FALSE for ascending, as in =SORT(A2:B5,2,FALSE), and you can add more column and order pairs.

</details>

## **Related functions**

- [**SORTBY**](https://practiceexcelonline.com/functions/sortby)
- [**FILTER**](https://practiceexcelonline.com/functions/filter)
- [**UNIQUE**](https://practiceexcelonline.com/functions/unique)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/functions/sort#webpage","description":"How to use SORT in Excel 365 and Google Sheets: a sorted copy of your data that updates by itself, by any column, up or down.","name":"SORT function in Excel: syntax and examples","url":"https://practiceexcelonline.com/functions/sort","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://practiceexcelonline.com/functions/sort#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"mainEntity":[{"@id":"https://practiceexcelonline.com/functions/sort#/schema/question/1"},{"@id":"https://practiceexcelonline.com/functions/sort#/schema/question/2"}],"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/functions/sort"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/functions/sort#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://practiceexcelonline.com/functions","position":2},{"@type":"ListItem","name":"SORT function in Excel: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/functions/sort#article","description":"How to use SORT in Excel 365 and Google Sheets: a sorted copy of your data that updates by itself, by any column, up or down.","headline":"SORT function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U09SVCBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBTT1JUIGluIEV4Y2VsIDM2NSBhbmQgR29vZ2xlIFNoZWV0czogYSBzb3J0ZWQgY29weSBvZiB5b3VyIGRhdGEgdGhhdCB1cGRhdGVzIGJ5IGl0c2VsZiwgYnkgYW55IGNvbHVtbiwgdXAgb3IgZG93bi4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U09SVChhcnJheSwgW3NvcnRfaW5kZXhdLCBbc29ydF9vcmRlcl0sIFtieV9jb2xdKQ%2Cp_Ii9mdW5jdGlvbnMvc29ydCI%2Cs_4kquZomZ-lVQ-fsu.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/functions/sort#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/functions/sort#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/functions/sort#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"Why does SORT return","acceptedAnswer":{"@type":"Answer","text":"The sorted result needs empty cells to spill into, and something is in the way. Clear the cells below and to the right of the formula."}},{"@id":"https://practiceexcelonline.com/functions/sort#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"Does SORT work the same way in Google Sheets?","acceptedAnswer":{"@type":"Answer","text":"Google Sheets has SORT too, but its arguments differ. You give the column to sort by and TRUE or FALSE for ascending, as in =SORT(A2:B5,2,FALSE), and you can add more column and order pairs."}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U09SVCBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBTT1JUIGluIEV4Y2VsIDM2NSBhbmQgR29vZ2xlIFNoZWV0czogYSBzb3J0ZWQgY29weSBvZiB5b3VyIGRhdGEgdGhhdCB1cGRhdGVzIGJ5IGl0c2VsZiwgYnkgYW55IGNvbHVtbiwgdXAgb3IgZG93bi4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U09SVChhcnJheSwgW3NvcnRfaW5kZXhdLCBbc29ydF9vcmRlcl0sIFtieV9jb2xdKQ%2Cp_Ii9mdW5jdGlvbnMvc29ydCI%2Cs_4kquZomZ-lVQ-fsu.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~U09SVCBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBTT1JUIGluIEV4Y2VsIDM2NSBhbmQgR29vZ2xlIFNoZWV0czogYSBzb3J0ZWQgY29weSBvZiB5b3VyIGRhdGEgdGhhdCB1cGRhdGVzIGJ5IGl0c2VsZiwgYnkgYW55IGNvbHVtbiwgdXAgb3IgZG93bi4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U09SVChhcnJheSwgW3NvcnRfaW5kZXhdLCBbc29ydF9vcmRlcl0sIFtieV9jb2xdKQ%2Cp_Ii9mdW5jdGlvbnMvc29ydCI%2Cs_4kquZomZ-lVQ-fsu.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
