0
0
Google Sheetsspreadsheet~10 mins

SORT and SORTN functions in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

This table shows names of students and their scores.

CellValue
A1Name
B1Score
A2Alice
B285
A3Bob
B392
A4Charlie
B478
A5Diana
B590
A6Evan
B688
Formula Trace
=SORTN(A2:B6, 3, 0, 2, FALSE)
Step 1: A2:B6
Step 2: SORT(A2:B6, 2, FALSE)
Step 3: SORTN(..., 3, 0, 2, FALSE)
Cell Reference Map
     A       B
  +-------+-------+
1 | Name  | Score |
  +-------+-------+
2 | Alice |  85   | <--
3 | Bob   |  92   | <--
4 | Charlie| 78   | <--
5 | Diana |  90   | <--
6 | Evan  |  88   | <--

Arrows show the data range A2:B6 used in the formula.
The formula uses the range A2:B6 which contains names and scores.
Result
     D       E
  +-------+-------+
1 | Name  | Score |
  +-------+-------+
2 | Bob   |  92   |
3 | Diana |  90   |
4 | Evan  |  88   |

This is the output of the formula =SORTN(A2:B6, 3, 0, 2, FALSE) showing top 3 scores sorted descending.
The formula result shows the top 3 students with highest scores sorted from highest to lowest.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the number 3 mean in the formula =SORTN(A2:B6, 3, 0, 2, FALSE)?
AIt limits the output to top 3 rows.
BIt sorts by the 3rd column.
CIt sorts ascending.
DIt skips the first 3 rows.
Key Result
SORTN(range, n, display_ties_mode, sort_column, is_ascending) returns top n rows sorted by a column.