How to Sort Data in Excel: Ascending, Descending and Custom

To sort data in Excel, click any cell in your data range, go to the Data tab, and select Sort A to Z (ascending) or Sort Z to A (descending). For multi-column sorts, open the Sort dialog box, add sort levels, and click OK. Always choose Expand the selection when prompted to keep all columns aligned.

  • One-click sort works for simple, single-column sorts directly from the Data tab or Home ribbon.
  • Multi-level sort lets you sort by Column A first, then Column B as a tiebreaker, using the Sort dialog box.
  • Always expand the selection when Excel asks, or your sorted column will detach from the rest of your rows.
  • Custom lists let you sort by non-alphabetical order, like month names or priority labels (High, Medium, Low).
  • The SORT function (Excel 365 and Excel 2021) returns a sorted array dynamically, without touching your original data.

Sort Basics: Ascending and Descending Order in Excel

Ascending and descending order in Excel describes the direction of a sort. Ascending (A to Z, 1 to 9, oldest to newest) arranges values from the smallest or earliest to the largest or latest. Descending flips that, so the biggest number or the most recent date appears at the top.

Say you have a list of 200 students from a Delhi college with their exam scores in Column B. You want to see who scored highest. Click any cell in Column B, go to Data > Sort Z to A, and Excel re-orders all 200 rows so the top scorer appears first. That is the complete process for a basic descending sort. The same logic applies to GST invoice data, employee payroll sheets, or any structured dataset common in Indian business workflows.

How to Sort a Single Column in Excel

  1. Click any cell inside the column you want to sort. Do not select the whole column or you will isolate it from the rest of the sheet.
  2. Go to the Data tab on the ribbon.
  3. Click Sort A to Z for ascending or Sort Z to A for descending.
  4. If Excel shows a Sort Warning dialog asking whether to expand the selection, always choose Expand the selection and click Sort.

That warning in step 4 is the most common trap beginners walk into. If you click Continue with the current selection instead, Excel sorts only that one column while every other column stays in its original order. Your student names and their scores will no longer match.

How to Sort by Date in Excel

Excel sorts dates numerically, so 01-Jan-2024 comes before 15-Mar-2024 in ascending order. Text is sorted character by character, so B12 sorts before B2 because 1 comes before 2 as text. If your numbers or dates are stored as text (you will see a green triangle in the cell corner), sorting will not work correctly. Convert them to numbers first using Data > Text to Columns or the Convert to Number option from the warning icon.

How to Sort Multiple Columns in Excel

Real datasets rarely need just one sort level. Imagine a sales report for a company like Infosys or TCS with columns for Region, Sales Rep, and Revenue. You want rows grouped by Region first, then sorted by Revenue (highest to lowest) within each region. That is a two-level sort, and the Sort dialog box handles it in about thirty seconds.

How to Sort by Two or More Columns

  1. Click any cell inside your data range.
  2. Go to Data > Sort to open the Sort dialog box.
  3. Under Sort by, pick your first sort column, for example Region, and set the order to A to Z.
  4. Click Add Level.
  5. Under Then by, pick Revenue and set the order to Largest to Smallest.
  6. Make sure My data has headers is checked if Row 1 contains column names.
  7. Click OK.

Excel processes levels from top to bottom. The first level is the primary sort; the second level only kicks in when two rows have the same value in the first column. You can add up to 64 sort levels, though in practice three or four is the maximum anyone ever needs.

Custom List Sorts

Alphabetical order does not always make sense. If your data has a Priority column with values like High, Medium and Low, sorting A to Z puts High first, then Low, then Medium, which is useless. A custom list fixes this.

  1. Open the Sort dialog box as above.
  2. In the Order dropdown, choose Custom List.
  3. In the Custom Lists dialog, click NEW LIST, type your values in order (High, Medium, Low, one per line) and click Add.
  4. Select that list and click OK.

Excel ships with built-in custom lists for months (January, February, March…) and weekdays. You can build your own for anything: product tiers, department names, project phases. Once saved, a custom list is available in every workbook on that machine.

Sort by Cell Colour or Font Colour

If you have used conditional formatting to flag overdue invoices in red, you can sort those to the top without writing a formula. In the Sort dialog, change the Sort On dropdown from Cell Values to Cell Color, pick the colour, and set the order to On Top. This is a practical trick that shows up in finance and operations work all the time.

How to Sort Data in Excel Without Losing Rows or Mixing Up Data

This is where most people learn the hard way. Sorting scrambles your data when Excel sorts only part of your range instead of the whole table. There are three main causes, and each one has a straightforward fix.

The Expand Selection Trap

When you select a single column and run a sort, Excel usually detects the adjacent data and asks if you want to expand the selection. Always say yes. If you do not, you end up with Column A sorted and Columns B through F untouched. In a student database, that means names in the wrong rows, which is a data integrity problem, not just a formatting one.

The safest habit: click a single cell inside the range rather than selecting an entire column before you sort. Excel will automatically detect the full contiguous range and sort all columns together.

Blank Rows and Merged Cells Break Sorts

A blank row in the middle of your data acts as a boundary. Excel treats the rows above and below the blank as separate ranges and sorts only one of them. Remove blank rows before sorting. Merged cells cause a similar problem; Excel refuses to sort a range that contains merged cells and throws an error. Unmerge them first using Home > Merge & Center > Unmerge Cells.

Keep a Row-Number Column as a Safety Net

On the job, a common practice is adding a helper column called Original Order or ID with sequential numbers (1, 2, 3…) before any sort. If you ever need to undo a sort after saving and closing the file, you can sort by that column to restore the original order. Ctrl+Z only works within the current session.

Data skills like these are exactly what hiring managers test during interviews. If you are preparing for analyst roles, check out these common data analyst interview questions to see how sorting, filtering and data cleaning come up in real assessments.

Sort Performance on Large Files

According to Microsoft’s Excel specifications and limits documentation, Excel worksheets support up to 1,048,576 rows per sheet. Sorting 500,000 rows with multiple levels can take a few seconds on an average machine. If you are working with datasets that large, consider converting your range to an Excel Table (Ctrl+T) first. Tables sort faster and the column headers automatically get filter dropdowns, which saves time during exploratory analysis.

Sort Method Best For Modifies Original Data? Available In
Data tab Sort A to Z / Z to A Quick single-column sorts Yes All Excel versions
Sort Dialog Box (multi-level) Two or more sort criteria Yes All Excel versions
Custom List Sort Non-alphabetical sequences Yes All Excel versions
SORT Function Dynamic, formula-based sorting No (outputs new range) Excel 365, Excel 2021
SORTBY Function Sort by a helper column not in output No (outputs new range) Excel 365, Excel 2021

SORT Function in Excel 365

The SORT function was introduced with Excel 365’s dynamic array engine and it changes how sorting data in Excel works entirely. Instead of rearranging your source data, SORT outputs a sorted copy of your range into a new location. The original table stays untouched.

SORT Function Syntax

The syntax is: =SORT(array, [sort_index], [sort_order], [by_col])

  • array: the range you want to sort, for example A2:C100.
  • sort_index: the column number to sort by (1 = first column in the array, 2 = second, and so on). Default is 1.
  • sort_order: 1 for ascending (default), -1 for descending.
  • by_col: FALSE to sort rows (default), TRUE to sort columns.

Example: =SORT(A2:C50, 3, -1) returns all 49 rows sorted by the third column in descending order. The result spills automatically into as many cells as it needs. If the source data changes, the sorted output updates instantly, no manual re-sort required.

SORTBY Function

SORTBY is more flexible. Its syntax is =SORTBY(array, by_array1, [sort_order1], [by_array2], [sort_order2]…). The key difference is that the column you sort by does not have to be in the output. Say you want to display only Name and Score (Columns A and B) but sort by a hidden helper column (Column D). SORTBY handles that cleanly: =SORTBY(A2:B50, D2:D50, -1).

Both functions are part of the broader dynamic array feature set that Microsoft rolled out to Excel 365 subscribers. If your organisation is still on Excel 2016 or 2019, you will not see these functions. Upgrading to Microsoft 365 is the only path to get them, and for analysts doing serious work, the dynamic array functions alone justify the subscription.

Excel skills sit near the top of required competencies for entry-level data roles. According to LinkedIn’s Jobs on the Rise report (2024), data analyst roles grew by over 25% year-on-year in India, with spreadsheet proficiency listed as a baseline requirement across virtually all postings. If you are building toward that career, take a look at what data analytics projects look like in practice, since most of them start with exactly this kind of data cleaning and sorting work. You can also explore entry-level tech jobs growing in 2026 to see which roles are actively hiring analysts with these skills right now.

NASSCOM’s 2024 India Tech Talent Report noted that over 1.4 million analytics and data science professionals are currently employed in India, with demand outpacing supply by roughly 30%. Sorting, filtering and transforming data in tools like Excel is step one of that skillset. For anyone figuring out data analyst kaise bane, mastering Excel is non-negotiable before moving to Python or SQL.

If you are weighing where to take your analytics career next, the comparison between a data analyst vs data scientist role is worth reading, since the tools and depth of Excel knowledge required differ significantly between the two paths.

Frequently Asked Questions

How do I sort data in Excel?

Click any cell inside your data range, go to the Data tab, and click Sort A to Z or Sort Z to A. For multi-column sorts, click Sort to open the full dialog box, add sort levels, and click OK. Always make sure My data has headers is checked if your first row contains column names.

What is ascending and descending order in Excel?

Ascending order in Excel means values are arranged from smallest to largest: A to Z for text, 1 to 9 for numbers, and oldest to newest for dates. Descending order reverses this, placing the largest value, the letter Z, or the most recent date at the top of the list. Both options appear as buttons on the Data tab.

How do I sort by two columns in Excel?

Go to Data > Sort to open the Sort dialog box. Set your first sort column using the Sort by dropdown, then click Add Level and set a second column under Then by. Excel sorts by the first column, then uses the second column to break ties within identical values in the first column.

How do I sort by date in Excel?

Click any cell in your date column, go to the Data tab, and click Sort A to Z for oldest to newest or Sort Z to A for newest to oldest. If dates are stored as text rather than date values, Excel will not sort them correctly. Check for a green triangle in the cell corner and use Convert to Number or Text to Columns to fix the format first.

Why does sorting mess up my data in Excel?

The most common cause is choosing Continue with the current selection when Excel’s Sort Warning appears, which sorts only the selected column while leaving all other columns in their original order. Blank rows in the middle of your data and merged cells also interrupt the sort range. Remove blanks, unmerge cells, and always choose Expand the selection when prompted.

What is the SORT function in Excel?

The SORT function is a dynamic array formula available in Excel 365 and Excel 2021. Its syntax is =SORT(array, sort_index, sort_order, by_col). It returns a sorted copy of your data in a new location without changing the source range. Because it is dynamic, the output updates automatically whenever the source data changes.

Sorting is one of those skills that looks simple until you break a dataset in front of a client. Knowing when to expand the selection, how to use multi-level sorts and when to reach for the SORT function instead of the Data tab separates someone who uses Excel from someone who actually knows how to sort data in Excel correctly. Here are three things you can do this week to lock this in:

  1. Open any existing spreadsheet you have, add a sequential ID column, then practise a three-level sort and sort it back using the ID. Get comfortable with the Sort dialog box until it feels automatic.
  2. If you have Excel 365, try the SORT function on a small dataset of 20 to 30 rows. Change a value in the source data and watch the output update instantly.
  3. Explore what the highest-paying tech skills in 2026 look like and map your Excel progress to the broader data skill stack employers are paying for right now.

Data skills do not stop at spreadsheets. Analysts who sort logs, build dashboards and flag anomalies in security operations use the same core thinking every day. If you want to take those skills into cybersecurity, the EC-Council Certified SOC Analyst course at 3.0 University is a practical next step for analysts who want to move into security operations. You can also browse the full catalogue of 3.0 University online certification courses in AI, Ethical Hacking, Blockchain and Web3. These are industry-recognised credentials built for working professionals and career switchers who want to move fast. Excel is the foundation; what you build on it is up to you.

Last updated: June 2025. Reviewed by the 3University editorial team.

We create, review, and maintain educational content covering Cybersecurity, Ethical Hacking, Artificial Intelligence, Blockchain, Web3, and emerging technologies.

Read More Articles