SORT Function in Google Sheets (Syntax and Examples)

SORT creates an ordered copy of a Google Sheets range while leaving the source in place. It can sort by numbers, text, or several columns in order.

Use TRUE for ascending order and FALSE for descending order. Include the whole record in the source range so labels stay with their values.

SORT function syntax

=SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])
  • range: the rows to return, normally excluding headers.
  • sort_column: a column position within the range, or a separate single-column range with the same row count.
  • is_ascending: TRUE for low to high or A to Z; FALSE reverses the order.
  • Additional column/direction pairs break ties in the order supplied.

The Google SORT reference describes the function arguments.

Example data

Enter this dataset starting in A1. Leave cells marked “leave empty” empty; type any displayed formula as a formula. Keep a separate blank area for the results.

ItemUnitsTeam
Pens55Red
Folders95Blue
Clips62Red
Pads80Blue
Ink50Red

The examples below use this dataset unless the formula supplies its own values. Array results need enough empty cells to expand. The formulas use commas as argument separators. Your spreadsheet locale may require semicolons.

Sort a table in ascending order

The second column contains units. Sorting it ascending puts Ink first at 50 and Folders last at 95, keeping each product and team together.

=SORT(A2:C6,2,TRUE)
Ink50Red
Pens55Red
Clips62Red
Pads80Blue
Folders95Blue
SORT orders the item table by units from 50 to 95.

Put the largest value first

Changing the direction to FALSE puts Folders first. The source table remains unchanged, and the sorted output recalculates when its source values change.

=SORT(A2:C6,2,FALSE)
Folders95Blue
Pads80Blue
Clips62Red
Pens55Red
Ink50Red

Sort text alphabetically

Column 1 contains product names. TRUE orders them alphabetically, starting with Clips. Numbers and team labels travel with their original product.

=SORT(A2:C6,1,TRUE)
Clips62Red
Folders95Blue
Ink50Red
Pads80Blue
Pens55Red

Sort by more than one column

Sort by team first, then units descending within each team. The second key resolves ties in the first key; it does not replace the first ordering.

=SORT(A2:C6,3,TRUE,2,FALSE)
Folders95Blue
Pads80Blue
Clips62Red
Pens55Red
Ink50Red

Sort a filtered result

FILTER keeps only products with more than 50 units. SORT orders those remaining rows by units descending.

=SORT(FILTER(A2:B6,B2:B6>50),2,FALSE)
Folders95
Pads80
Clips62
Pens55

For values between 50 and 60 inclusive, use both bounds inside FILTER, then sort the resulting single column ascending.

=SORT(FILTER(B2:B6,B2:B6>=50,B2:B6<=60),1,TRUE)
50
55

Use a separate sort-key column

Return just the product names while using B2:B6 as the ordering key. This keeps the key out of the displayed result.

=SORT(A2:A6,B2:B6,FALSE)
Folders
Pads
Clips
Pens
Ink

Other Google Sheets articles you may also like