July 2, 2022

# How to use SORT Function in Excel

The Excel SORT function sorts the contents of a range or array. Values can be sorted by one or more columns. SORT returns a dynamic array of results.

Syntax:= SORT (array, [sort_index], [sort_order], [by_col])

The SORT function syntax has the following arguments:

• array – Range or array to sort.
• sort_index – [optional] Column index to use for sorting. Default is 1.
• sort_order – [optional] 1 = Ascending, -1 = Descending. Default is ascending order.
• by_col – [optional] TRUE = sort by column. FALSE = sort by row. Default is FALSE.

Example: Let’s look at some Excel SORT function examples and explore how to use the SORT function as a worksheet function in Microsoft Excel: Let’s say we want to sort the table in cells A2:E10 based on the Item column (C). We can use the SORT function like so:

Syntax: A13 =SORT(A2:E10;2;1)

Result: We expect one of the most common uses for SORT will be to sort a UNIQUE List. In the example below, We’ve used the UNIQUE function to extract a list from the Items in column (B), and then wrapped it in the SORT function:

Syntax: A12=SORT(UNIQUE(B2:B10))

Result: Let’s say you want to sort by Items and then by Department in descending order. You can pass an array of sort_index arguments by surrounding them in curly braces and then separating them with a comma, as shown below:

Syntax: A13=SORT(A2:E10;{2,1};1) READ:  How to use the Excel LOOKUP function #### Excel

View all posts by Excel →