What is SORTN in Google Sheets?

SORTN sorts a range and returns only the first N rows. You choose how many rows, which column drives the sort, and ascending or descending order. Leaderboards and best-seller reports use SORTN instead of manual sorting that goes stale.

When to use it

Use SORTN for top ten lists, bottom performers, or largest invoices where the cutoff count is fixed.

When to skip it

Skip SORTN when you need all rows sorted. Use SORT instead. Complex tie-breaking may need QUERY with multiple ORDER BY columns.

How it works

  1. 1

    Pass the full data array including headers if you want them in output.

  2. 2

    Set n to how many rows to return after sorting.

  3. 3

    Choose display_ties_mode when equal values should all appear or be cut off.

  4. 4

    Pick the sort column index and TRUE for ascending or FALSE for descending.

  5. 5

    Leave spill room for n rows plus header if included.

  6. 6

    Refresh source data so SORTN rankings update on dashboards.

Examples in Google Sheets

Top ten reps

=SORTN(A2:D100, 10, 2, FALSE, 3) returns ten rows sorted by revenue column descending.

Lowest inventory

=SORTN(Stock!A:C, 5, 3, TRUE) shows five SKUs with smallest on-hand counts.

Student honors

=SORTN(Grades!A:D, 15, 4, FALSE) lists top fifteen GPA rows for the dean list.

Build this without starting from a blank cell

Use a Better Sheets tool for SORTN, then watch a walkthrough when you want the full pattern.

Better Sheets resources

Common mistakes

  • Using wrong sort column index after inserting a new column left of the key.
  • Expecting SORTN to aggregate duplicates before ranking.
  • Setting n larger than available rows without handling short lists.
  • Including header row in sort range so a text header sorts into results.
  • Confusing SORTN arguments with SORT single-key syntax.

Frequently asked questions

SORTN vs SORT?
SORT returns all rows ordered. SORTN caps how many rows return.
How are ties handled?
display_ties_mode controls whether tied rows all appear or truncate at n.
Multiple sort keys?
Add more sort column arguments per SORTN documentation for secondary keys.
SORTN with FILTER?
FILTER first to a subset, then SORTN for top rows within that slice.
Why wrong top ten?
Check sort column index, text numbers, and blank rows affecting order.
Can SORTN sort by date?
Yes when dates are real serial numbers, not text.
SORTN and QUERY LIMIT?
Both cap rows. SORTN is native array syntax; QUERY LIMIT uses SQL strings.

Related Tutorials

Watch how SORTN works

Browse more tutorials
How To Format Sheets for Notes

How To Format Sheets for Notes

Create sortable notes in Three ways.  1. By adding the original word ove...
Combine Sheets Into One Sheet As It Happens

Combine Sheets Into One Sheet As It Happens

Jodi asked:  ab out Building a sales CRM spreadsheet that has 4-5 tabs a...
How To Sort A Filter

How To Sort A Filter

This will allows you to analyze and organize your data.
Search Every Function in Google Sheets

Search Every Function in Google Sheets

Built a useful tool to filter Google Sheet formulas based on keywords.

Related blog posts

Guides that explain SORTN in more depth.

Browse the blog

Related glossary terms

Done reading about SORTN?

Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.

Need this once

Jump to a free tool or a single tutorial for this topic.

Learning Sheets for real

Unlock the full library, generators, and templates with membership.