Google Sheets Function: SORT
The SORT function sorts the rows of a range based on the values of one or more columns.
Usage:
=SORT(range, sort_column, is_ascending)
or
=SORT(range, sort_column_1, is_ascending_1,
sort_column_2, is_ascending_2, etc)
Example of use
The SORT function will return in the green table all the rows from the blue table sorted by name:
Enter in the SORT function:
- range: the range of data
- sort_column: the column of the range by which the data will be sorted
- is_ascending: 1 for ascending order, 0 for descending order
The formula here is:
=SORT(A2:C21,1,1)
Sorting based on multiple columns
To perform sorting based on multiple columns, add sort_column and is_ascending values for each additional column.
For example, to sort by name and then by first name, enter:
=SORT(A2:C21,1,1,2,1)
If needed, you can copy the Google Sheets document (or view the document) with this example.