# SORT in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/sort/

SORT returns the rows of a range in a new order, by one or several columns, without changing the original data. The result spills into the cells below and to the right of the formula.

## Syntax

```
SORT(range, sort_column, is_ascending, [sort_column2], [is_ascending2])
```

## Arguments

- `range` (range, required: yes): The rows to sort. The header row should stay outside.
- `sort_column` (number, required: yes): Which column of range to sort by, counted from 1 inside range.
- `is_ascending` (boolean, required: yes): TRUE for A to Z and small to large, FALSE for the reverse.
- `sort_column2` (number, required: no): A second column used to break ties.
- `is_ascending2` (boolean, required: no): Direction for the second column.

## Examples

The examples use this table, starting in A1:

| Region | Product | Units | Price |
|---|---|---|---|
| North | Pen | 10 | 2.5 |
| South | Pen | 4 | 2.5 |
| North | Book | 3 | 12 |
| East | Book | 8 | 12 |
| South | Lamp | 5 | 30 |

```
=SORT(A2:D6, 3, FALSE)
```

Result: 

| North | Pen | 10 | 2.5 |
|---|---|---|---|
| East | Book | 8 | 12 |
| South | Lamp | 5 | 30 |
| South | Pen | 4 | 2.5 |
| North | Book | 3 | 12 |

All rows ordered by units, largest first. The result spills into a block that starts in the formula cell. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(A2:D6, 2, TRUE, 3, FALSE)
```

Result: 

| East | Book | 8 | 12 |
|---|---|---|---|
| North | Book | 3 | 12 |
| South | Lamp | 5 | 30 |
| North | Pen | 10 | 2.5 |
| South | Pen | 4 | 2.5 |

Two keys: product A to Z first, then units from large to small inside each product. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(A2:A6, 1, FALSE)
```

Result: 

| South |
|---|
| South |
| North |
| North |
| East |

One column only, Z to A. Duplicates stay. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(FILTER(A2:C6, C2:C6>4), 3, TRUE)
```

Result: 

| South | Lamp | 5 |
|---|---|---|
| East | Book | 8 |
| North | Pen | 10 |

SORT on top of FILTER: keep rows with more than 4 units, then order them upward. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(A1:D6, 3, TRUE)
```

Result: 

| North | Book | 3 | 12 |
|---|---|---|---|
| South | Pen | 4 | 2.5 |
| South | Lamp | 5 | 30 |
| East | Book | 8 | 12 |
| North | Pen | 10 | 2.5 |
| Region | Product | Units | Price |

The header row is inside the range here, so the text Units is sorted like data and lands at the bottom. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- is_ascending is required, even though it looks like a small detail. =SORT(A2:D6, 3) returns #N/A. Write TRUE or FALSE.
- sort_column counts inside range, not on the sheet. A number higher than the width of range raises no error: the rows come back in their original order, which looks like SORT did nothing.
- If the header row is inside range, it is sorted with the data. In a number column sorted upward it ends at the bottom. Leave it outside.

## Compared with Excel

Excel 365 has SORT(array, [sort_index], [sort_order], [by_col]), where the order is 1 or -1 and the column is optional. Sheets asks for TRUE or FALSE and takes extra keys as column and direction pairs.

## Related functions

- [SORTN](https://goingstellar.ro/reference/sheets/sortn/)
- [FILTER](https://goingstellar.ro/reference/sheets/filter/)
- [UNIQUE](https://goingstellar.ro/reference/sheets/unique/)
- [QUERY](https://goingstellar.ro/reference/sheets/query/)
- [ARRAYFORMULA](https://goingstellar.ro/reference/sheets/arrayformula/)
- [INDEX](https://goingstellar.ro/reference/sheets/index/)

## Sources

- [SORT (Docs Editors Help)](https://support.google.com/docs/answer/3093150)

