Sort your data with SORT and SORTBY in Excel

Sorting your data is often the first reflex as soon as you open a somewhat cluttered Excel spreadsheet. Whether it’s to sort names alphabetically, quickly identify the most significant sales, or structure a report, the SORT and SORTBY functions have become essential. In this article, I guide you step by step: from a simple column to multi-criteria organization, you will see how these formulas can transform your way of working.

Why sort your data in Excel?

Improve readability

Imagine a list of 200 mixed clients: some in uppercase, others in lowercase, with no apparent order. You waste a lot of time finding a line. By sorting, you align first names and last names in order, homogenize the presentation, and navigation becomes smooth. The simple act of moving from a “random” order to an alphabetical or chronological order makes the table much more approachable.

Prepare analysis and reports

In a financial or marketing context, numbers are often sorted — from the highest turnover to the lowest, or vice versa. This ranking serves as a basis for charts, dashboards, or control points to detect anomalies. Without prior sorting, a bar chart can skew your axes and distort your interpretation.

The SORT function: principle and examples

Syntax and parameters

The SORT function (TRIER in French) is based on a simple structure:

=SORT(range; [column_index]; [order]; [by_column])

  • range: the range of cells to sort.
  • column_index (optional): number of the column used as the sort key.
  • order (optional): 1 for ascending, -1 for descending.
  • by_column (optional): TRUE to sort by columns, FALSE (default) to sort by rows.

The big advantage is that SORT returns a new dynamic array without modifying the original data.

Simple example: sorting a column of names

Suppose A2:A20 contains a list of first names. In B2, type:

=SORT(A2:A20;1;1)

In the blink of an eye, Excel aligns the first names from A to Z in column B. If you change the order to -1, it goes from Z to A.

The SORTBY function: moving beyond one-dimensional sorting

When to use SORTBY?

To sort according to multiple criteria, SORTBY (TRIERPAR) takes over. Want to organize your sales first by geographic area, then by descending amount? SORTBY is made for you.

Syntax and multi-criteria example

The basic model:

=SORTBY(range_to_sort; criteria_range1; order1; [criteria_range2; order2]; …)

Practical example: your sales are in B2:D100, the zone in C2:C100, the figure in D2:D100. In E2:

=SORTBY(B2:D100; C2:C100; 1; D2:D100; -1)

You first get all rows for zone A, sorted from the highest to the lowest amount, then those for zone B, etc.

Summary table: SORT vs SORTBY

Function Main advantage
SORT Fast and dynamic one-dimensional sorting
SORTBY Multi-criteria sorting across multiple columns simultaneously

Advanced use cases

Sort after splitting cells

Sometimes, your data is stored in the same cell: “Dupont Alice”. Before sorting by last name, it may be wise to extract the last name and first name into two separate columns. The LEFT, RIGHT, or MID functions (text functions) then become your allies. Once the names are isolated, SORT or SORTBY immediately provides a coherent ranking.

Create a dynamic dashboard with VLOOKUP and SORTBY

Do you want a dashboard to automatically display the top 5 of your best sellers? Combine SORTBY with VLOOKUP to extract the associated information (quantity, date, region). Thanks to this tip, as soon as your numbers are updated, your mini-report will recalculate itself.

Segmentation and slicers in a PivotTable: a powerful complement

Rather than multiplying formulas, you can also insert a pivot table and add slicers to filter by month, by product, by region… This works in concert with SORTBY because, once filters are applied, the sorted data area becomes ultra-selective and allows you to focus on a precise subset.

Tip: sort without formulas

Sometimes manual manipulation is preferred, especially for a one-off. Select your range, then in the ribbon, Data > Sort. You choose the column, the order, and voilà: the sort is done in place. Useful for occasional adjustments, but beware: your original data is moved — remember to save a copy!

Best practices and pitfalls to avoid

  • Separate your sources: always work on a copy or on a named range to preserve the original.
  • Check the headers: Excel may include your titles in the sort if you forget to check “My data has headers.”
  • Standardize the format: dates must all be in the same format, otherwise Excel sorts texts before dates.
  • Prefer tables: by converting your list into a “Table” (Ctrl + T), dynamic ranges are automatically taken into account.

Conclusion

The SORT and SORTBY functions are real game-changers as soon as it comes to restoring order and logic in your Excel tables. Simple to use for basic sorting, they gain power as soon as you ask them for multiple criteria or integration with other formulas. By mastering these tools, you will not only save time but also facilitate the creation of reliable and aesthetic reports.

So, ready to click on your first SORTBY formula? Try it now and say goodbye to tedious rankings!

Leave a comment