Sort a range with SORT and SORTBY
SORT returns a sorted copy of a range that updates when the source changes, without touching the original data.
=SORT(A2:C100,3,-1)The sheet: A table in A2:C100 has Name, Region and Revenue (column C). You want a live copy sorted by revenue, highest first.
How it works, step by step
- 01A2:C100 is the range to sort.
- 023 means sort by the third column of that range, Revenue.
- 03-1 means descending. Use 1 for ascending.
- 04The sorted table spills into the cells below and to the right.
The same logic in four tools
=SORT(A2:C100,3,-1)=SORT(A2:C100,3,FALSE)SELECT name, region, revenue
FROM sales
ORDER BY revenue DESC;sorted_df = df.sort_values("revenue", ascending=False)Mistakes that break it
- !Excel uses -1 for descending, while Google Sheets uses FALSE.
- !Excel also has SORTBY, which sorts by a separate range such as =SORTBY(A2:C100,C2:C100,-1). Google Sheets has no SORTBY.
- !A spill range needs empty cells under and beside the formula.
Common questions
- How do I sort by two columns?
- In Excel pass arrays, =SORT(A2:C100,{2,3},{1,-1}). In Sheets add more pairs: =SORT(A2:C100,2,TRUE,3,FALSE).
- Does it change my original data?
- No. The Data menu sort changes the source, while the SORT function leaves it alone.
Got a version of this with your own ranges?
Paste it into the free translator and get the same breakdown for your exact formula. To run it against a real file, upload the CSV and describe the formula you need in a sentence.