# Excel 2019: Sorting with a Formula

September 09, 2019 - by Bill Jelen

Sorting data in Excel is easy. Unless, you are building a dashboard for your manager's manager. You can't ask that person to select C3, go to the Data tab and click the AZ button every time they want an updated report. The new SORT and SORTBY functions allow you to easily sort with a formula.

You can pass three arguments to the SORT function. The first is the range to be sorted. Leave the headings out of this argument. Next, which column do you want to sort by. If your data is in B:D and you want to sort by column D, you would specify column 3 as the sort column. The third argument is a 1 for ascending or -1 for descending.

In this figure, the data is sorted by Amount descending:

What if you want to do a two-level sort? You can specify an array constant for both the second and third argument. In this case, the data is sorted by Team ascending and Amount descending. For the sort column, specify {2;3}. For the sort order, specify {1,-1}.

The Excel Calc team also gave you the SORTBY function. Say you want to return a list of products but not the associated amounts. You want the products to be sorted by the amount. The formula below says to return the products from B3:B9 sorted descending by the amounts in D3:D9.

Title Photo: John Such at Unsplash.com

##### Bill Jelen is the author / co-author ofExcel Dynamic Arrays Straight to the Point 2nd Edition

Fifteen months after Dynamic Arrays debuted for Office Insiders, the functions are being released to General Availability. This second edition of the book has been updated with new examples: see how Dynamic Arrays make XLOOKUP better. The chapter on the logic behind arrays has been expanded.