Array

SORT Formula

Returns a sorted version of an array or range without modifying the original data. SORT is a dynamic array function that automatically spills its results, making it ideal for creating live-sorted views of data that update as the source changes. No more manually re-sorting after adding new rows.

Syntax

SORT(array, [sort_index], [sort_order], [by_col])
ParameterDescription
array Parameter of the SORT function.
[sort_index] (Optional.) Parameter of the SORT function.
[sort_order] (Optional.) Parameter of the SORT function.
[by_col] (Optional.) Parameter of the SORT function.
Try SORT in Viztab — free, no signup

Examples

Sort names alphabetically

Formula
=SORT(A2:B20, 1, 1)
Returns all rows from A2:B20 sorted by column 1 (names) in ascending order (A to Z).

Sort sales descending

Formula
=SORT(A2:C50, 3, -1)
Returns the data sorted by column 3 (sales) in descending order — highest sales first.

Sort by multiple columns

Formula
=SORT(SORT(A2:D100, 2, 1), 1, 1)
Nested SORT: first sorts by column 2, then by column 1. The outer SORT takes priority. Useful for sorting by department then by name.

Common Errors

#VALUE!

The sort_index is zero or exceeds the number of columns (or rows if sorting by column).

#SPILL!

The destination cells where results would spill are not empty.

Tips

Non-destructive sorting

Unlike the Sort button in the toolbar, SORT creates a sorted copy in a new location. Your original data stays untouched and the sorted view updates automatically.

Use -1 for descending

The sort_order argument uses 1 for ascending and -1 for descending. This is different from TRUE/FALSE used in some older functions.

Combine with FILTER

Use =SORT(FILTER(A2:C100, C2:C100>1000), 3, -1) to first filter rows, then sort the results. This creates a powerful dynamic dashboard view.

Try SORT in Viztab

Import your data and use SORT with 370+ other formulas. No signup required.

Open Viztab

Related Formulas