DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Use Excel SORTBY Function in Excel Office 365?

The SORTBY Function of Excel can return a sorted array by another independent array , and you can add levels of sorting. In this tutorial, we are going to see how to use the Excel SORTBY Function In Excel Office 365. Let’s get into this article!! Get an official version of ** MS Excel** from the following link: https://www.microsoft.com/en-in/microsoft-365/excel

SORTBY Function Syntax

=SORTBY(array,sorting_array1,[order],…)
Enter fullscreen mode Exit fullscreen mode

Syntax Explanation:

  • Array : This is the array that you want to sort.
  • Sorting_array1 : This is the array by which you want to sort the array. The dimension of this array should be compatible with the array.
  • [order]: Optional. Set it to -1 if you want the order to be descending. By default, it is ascending(1).

Example

  • You need to create a sample data of participants with their IDs and scores.

Sample data

  • Then, you have to get the names sorted by their IDs using the SORTBY function.
  • Now, you need to use the generic formula to get the ascending sorted names by ID column.
=SORTBY(A2:A10,B2:B10)
Enter fullscreen mode Exit fullscreen mode

ascending sorted names

  • After that, if you want to get whole table, than just give reference of whole table.
=SORTBY(A2:A10,B2:B10)
Enter fullscreen mode Exit fullscreen mode
  • Then, if you want the range to be sorted descending by ID column , then the formula will be:
=SORTBY(A2:A10,B2:B10,-1)
Enter fullscreen mode Exit fullscreen mode

Example: Sort Array by More Than One Column

  • Here, in the above examples, you have sorted the array by just one column.
  • Then, you want to first sort the above table ascending by ID and then sort the array descending by the score.
  • Now, you need to use the formula given below.
=SORTBY(A2:A10,B2:B10,1,C2:C10,-1)
Enter fullscreen mode Exit fullscreen mode

Check this too: How to Use Excel SORT Function in Office 365? – [with Example]

Wrap-Up

Hope you understood how to use the Excel SORTBY Function In Excel Office 365. Please feel free to state your query or feedback for the above article. Thank you so much for Reading!! To learn more, check out Geek Excel!! *and Excel Formulas *!!

Read Ahead:

Top comments (0)