FormulaCraft

SORTBY

SORTBY is a dynamic array function that returns a sorted copy of an array ordered by the values in a corresponding by-array, without requiring the sort key to be part of the output. It supports multiple sort levels and spills results automatically into adjacent cells.

Excel
=SORTBY(A2:B5,B2:B5,-1)
Google Sheets
=SORTBY(A2:B5,B2:B5,-1)

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

How it works

  1. 1Select the range you want to sort (e.g. A2:B5 containing names and scores).
  2. 2Specify the sort-by range (e.g. B2:B5, the scores column) and direction: 1 for ascending, -1 for descending.
  3. 3Enter =SORTBY(array, by_array, sort_order) in an empty cell and the sorted table spills automatically.

Need a version for your data?

Try: “Sort my list of students by their exam score from highest to lowest.

Related

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: