Sort data with a formula
=SORT(A2:B7,2,-1)Excel · result on the sample sheet: 6 rows (D2:E7)
Describe what you need and get a working SORT formula for Excel and Google Sheets, tested on real data before you copy it. SORT returns a sorted copy of a range, ordered by any column you choose, smallest to largest or the reverse.
Each formula below was calculated on its own sample sheet. Open one to see the sheet, why it works, and to try it yourself.
=SORT(A2:B7,2,-1)Excel · result on the sample sheet: 6 rows (D2:E7)
=SORT(A2:C9,{2,3},{1,-1})Excel · result on the sample sheet: 8 rows (E2:G9)
=UNIQUE(B2:B8)Excel · result on the sample sheet: 4 rows (E2:E5)
=SORT(UNIQUE(B2:B10))Excel · result on the sample sheet: 5 rows (D2:D6)
=SORT(UNIQUE(FILTER(B2:B,B2:B<>"")))Google Sheets · result on the sample sheet: 5 rows (D2:D6)
=SORTBY(A2:C8,DATEVALUE(A2:A8))Excel · result on the sample sheet: 7 rows (E2:G8)
=SORTBY(A2:B9,MONTH(B2:B9),1,DAY(B2:B9),1)Excel · result on the sample sheet: 8 rows (D2:E9)
=SORT(FILTER(A2:C11,B2:B11=MAXIFS(B2:B11,A2:A11,A2:A11)))Excel · result on the sample sheet: 4 rows (E2:G5)
You describe the task in plain English, and it writes the formula, using SORT where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.
SORT returns a sorted copy of a range, ordered by any column you choose, smallest to largest or the reverse.
Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the SORT function page has a practice exercise.