Skip to main content

SORT function

The SORT function is one of the lookup and reference functions. It is used to sort a range of data or an array and to return the sorted array.

Syntax​

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

The SORT function has the following arguments:

ArgumentDescription
arrayThe range of data to sort.
sort_indexAn optional argument. A number identifying the column or the row to sort by.
sort_orderAn optional argument. A number determining the sorting order:

• 1 or omitted for ascending order (by default),
• -1 for descending order.
by_colAn optional argument. A value indicating the sorting direction:

• FALSE or omitted for sorting by rows when your data is organized vertically.
• TRUE for sorting by columns when your data is organized horizontally.

Notes​

Please note that this is an array formula. To learn more, please read the Insert array formulas article.

How to apply the SORT function.

Examples​

The figure below displays the result returned by the SORT function.

SORT Function