0
0
Google Sheetsspreadsheet~5 mins

SORT and SORTN functions in Google Sheets - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
SORT and SORTN help you organize your data by arranging rows in order. SORT puts all rows in order based on one or more columns. SORTN lets you pick the top rows after sorting, like the top 5 scores.
When you want to list your sales data from highest to lowest sales amount.
When you need to show the top 3 students with the best grades.
When you want to sort a list of names alphabetically.
When you want to sort data by date to see the newest entries first.
When you want to extract the top 10 highest values from a large list.
Steps
Step 1: Click
- an empty cell where you want the sorted data to appear
The cell is selected and ready for formula input
Step 2: Type
- the selected cell
The formula starts to appear in the formula bar
💡 Start with =SORT( to sort all rows
Step 3: Enter
- the range of cells you want to sort, for example A2:C10
The range is included in the formula
Step 4: Type
- after the range, add the column number to sort by, for example 2 for the second column
The formula now knows which column to sort by
Step 5: Type
- after the column number, add TRUE for ascending or FALSE for descending order
The formula is complete and ready to run
Step 6: Press
- Enter key
The sorted data appears starting from the selected cell
Step 7: To use SORTN, repeat steps 1-3, then type =SORTN(range, n, 0, sort_column, TRUE/FALSE)
- the selected cell
Only the top n rows sorted by the chosen column appear
Before vs After
Before
A list of sales data with names and amounts in random order
After
The same list sorted by sales amount from highest to lowest starting at the chosen cell
Settings Reference
range
📍 inside the SORT or SORTN formula
The data you want to sort
Default: none
sort_column
📍 inside the SORT or SORTN formula after the range
Which column to sort by
Default: 1
is_ascending
📍 inside the SORT or SORTN formula after the sort_column
Sort order direction
Default: TRUE
n (for SORTN)
📍 inside the SORTN formula as the second argument
Number of top rows to return after sorting
Default: 1
Common Mistakes
Using SORT without specifying the sort order (TRUE or FALSE)
Google Sheets may default to ascending, which might not be what you want
Always include TRUE for ascending or FALSE for descending to control order
Using SORTN without setting the correct number of rows to return
You might get only one row or too many rows, not the intended top results
Set the second argument in SORTN to the exact number of rows you want
Sorting a range that includes headers
Headers get mixed with data and sorted incorrectly
Select only the data range without headers or freeze headers separately
Summary
SORT arranges all rows in order based on one or more columns.
SORTN returns the top rows after sorting, useful for showing best or worst values.
Always specify the sort column and order to get the expected results.