Sort function in Excel

Hello all. In this section let’s look at SORT function in excel. Sort function, as the name says, sorts the content of a range or an array based on the optional arguments we specify. Values, using this function, can be sorted by rows or columns and the function returns dynamic array.


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

Here, array is the values which needs to be sorted. [Sort_Index] is the number that denotes which column in the array has to be sorted. [Sort_order] denotes whether the sort will be ascending or descending. [by_col] denotes whether the sort happens by column or row


Let’s use the below data set to use sort function with various arguments. First, let’s use the sort function without any optional arguments

SORT function without arguments

Here, the function has sorted the first column by default and sorted ascending by default. Now, let’s sort the 2nd column (sorting students based on their scores)

Sorting by scores

In the above pic, we have given “2” for the function to sort by the values in 2nd column. Again by default it has sorted ascending. If we need to sort by descending, let’s add “-1” after “2”

Sorting by forced column number and type

In the above example, we were looking at values arranged vertically. What will happen when we use sort function?

Default sort function

SORT function, without any arguments, for horizontally arranged data doesn’t really sort any values. And you may notice “score” row has come as the first row – because SORT function, by default, sort by row (between 93 and Sachin, 93 comes first and hence 93 came as first row). If you need to sort horizontally arranged values, we need to force the function to sort by column (each value is a column)

I hope you like this section. Please help us with your feedback. Thanks for reading!

Leave a Reply

%d bloggers like this: