How to do sorting in excel

Connect with an expert. Learn from live instructors.

Sorting data is an integral part of data analysis. You might want to arrange a list of names in alphabetical order, compile a list of product inventory levels from highest to lowest, or order rows by colors or icons. Sorting data helps you quickly visualize and understand your data better, organize and find the data that you want, and ultimately make more effective decisions.

You can sort data by text (A to Z or Z to A), numbers (smallest to largest or largest to smallest), and dates and times (oldest to newest and newest to oldest) in one or more columns. You can also sort by a custom list you create (such as Large, Medium, and Small) or by format, including cell color, font color, or icon set.

Notes: 

  • To find the top or bottom values in a range of cells or table, such as the top 10 grades or the bottom 5 sales amounts, use AutoFilter or conditional formatting.

  • For more information, see Filter data in an Excel table or range, and Apply conditional formatting in Excel .

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Sort text

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, do one of the following:

    • To quick sort in ascending order, click A to Z command in Excel that sorts A to Z or smallest number to largest (Sort A to Z).

    • To quick sort in descending order, click Z to A command in Excel that sorts Z to A or largest number to smallest (Sort Z to A).

Notes: 
Potential Issues

  • Check that all data is stored as text    If the column that you want to sort contains numbers stored as numbers and numbers stored as text, you need to format them all as either numbers or text. If you do not apply this format, the numbers stored as numbers are sorted before the numbers stored as text. To format all the selected data as text, Press Ctrl+1 to launch the Format Cells dialog, click the Number tab and then, under Category, click General, Number, or Text.

  • Remove any leading spaces    In some cases, data imported from another application might have leading spaces inserted before data. Remove the leading spaces before you sort the data. You can do this manually, or you can use the TRIM function.

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, do one of the following:

    • To sort from low to high, click A to Z command in Excel that sorts A to Z or smallest number to largest (Sort Smallest to Largest).

    • To sort from high to low, click Z to A command in Excel that sorts Z to A or largest number to smallest (Sort Largest to Smallest).

Notes: 

  • Potential Issue   

  • Check that all numbers are stored as numbers    If the results are not what you expected, the column might contain numbers stored as text instead of as numbers. For example, negative numbers imported from some accounting systems, or a number entered with a leading apostrophe () are stored as text. For more information, see Fix text-formatted numbers by applying a number format.

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, do one of the following:

    • To sort from an earlier to a later date or time, click A to Z command in Excel that sorts A to Z or smallest number to largest (Sort Oldest to Newest).

    • To sort from a later to an earlier date or time, click Z to A command in Excel that sorts Z to A or largest number to smallest (Sort Newest to Oldest).

Notes: 
Potential Issue   

  • Check that dates and times are stored as dates or times    If the results are not what you expected, the column might contain dates or times stored as text instead of as dates or times. For Excel to sort dates and times correctly, all dates and times in a column must be stored as a date or time serial number. If Excel cannot recognize a value as a date or time, the date or time is stored as text. For more information, see Convert dates stored as text to dates.

  • If you want to sort by days of the week, format the cells to show the day of the week. If you want to sort by the day of the week regardless of the date, convert them to text by using the TEXT function. However, the TEXT function returns a text value, so the sort operation would be based on alphanumeric data. For more information, see Show dates as days of the week.

You may want to sort by more than one column or row when you have data that you want to group by the same value in one column or row, and then sort another column or row within that group of equal values. For example, if you have a Department column and an Employee column, you can first sort by Department (to group all the employees in the same department together), and then sort by name (to put the names in alphabetical order within each department). You can sort by up to 64 columns.

Note: For best results, the range of cells that you sort should have column headings.

  1. Select any cell in the data range.

    Employee list by department to be sorted

  2. On the Data tab, in the Sort & Filter group, click Sort.

    The Sort & Filter group on the Data tab

  3. In the Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.

    Select the first column to sort

  4. Under Sort On, select the type of sort. Do one of the following:

    • To sort by text, number, or date and time, select Values.

    • To sort by format, select Cell Color, Font Color, or Cell Icon.

  5. Under Order, select how you want to sort. Do one of the following:

    • For text values, select A to Z or Z to A.

    • For number values, select Smallest to Largest or Largest to Smallest.

    • For date or time values, select Oldest to Newest or Newest to Oldest.

    • To sort based on a custom list, select Custom List.

  6. To add another column to sort by, click Add Level, and then repeat steps three through five.

    Click Add Level

  7. To copy a column to sort by, select the entry and then click Copy Level.

  8. To delete a column to sort by, select the entry and then click Delete Level.

    Note: You must keep at least one entry in the list.

  9. To change the order in which the columns are sorted, select an entry and then click the Up or Down arrow next to the Options button to change the order.

    Entries higher in the list are sorted before entries lower in the list.

If you have manually or conditionally formatted a range of cells or a table column by cell color or font color, you can also sort by these colors. You can also sort by an icon set that you created with conditional formatting.

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, click Sort.

    The Sort & Filter group on the Data tab

  3. In the Sort dialog box, under Column, in the Sort by box, select the column that you want to sort.

    Under Column, click Sort by, and choose an option

  4. Under Sort On, select Cell Color, Font Color, or Cell Icon.

    Under Sort On, choose an option

  5. Under Order, click the arrow next to the button and then, depending on the type of format, select a cell color, font color, or cell icon.

  6. Next, select how you want to sort. Do one of the following:

    • To move the cell color, font color, or icon to the top or to the left, select On Top for a column sort, and On Left for a row sort.

    • To move the cell color, font color, or icon to the bottom or to the right, select On Bottom for a column sort, and On Right for a row sort.

      Note: There is no default cell color, font color, or icon sort order. You must define the order that you want for each sort operation.

  7. To specify the next cell color, font color, or icon to sort by, click Add Level, and then repeat steps three through five.

    Make sure that you select the same column in the Then by box and that you make the same selection under Order.

    Keep repeating for each additional cell color, font color, or icon that you want included in the sort.

You can use a custom list to sort in a user-defined order. For example, a column might contain values that you want to sort by, such as High, Medium, and Low. How can you sort so that rows containing High appear first, followed by Medium, and then Low? If you were to sort alphabetically, an “A to Z” sort would put High at the top, but Low would come before Medium. And if you sorted “Z to A,” Medium would appear first, with Low in the middle. Regardless of the order, you always want “Medium” in the middle. By creating your own custom list, you can get around this problem.

  1. Optionally, create a custom list:

    1. In a range of cells, enter the values that you want to sort by, in the order that you want them, from top to bottom as in this example.

      Create a list from high to low in a range of cells

    2. Select the range that you just entered. Using the preceding example, select cells A1:A3.

    3. Go to File > Options > Advanced > General > Edit Custom Lists, then in the Custom Lists dialog box, click Import, and then click OK twice.

      Notes: 

      • You can create a custom list based only on a value (text, number, and date or time). You cannot create a custom list based on a format (cell color, font color, or icon).

      • The maximum length for a custom list is 255 characters, and the first character must not begin with a number.

  2. Select a cell in the column you want to sort.

  3. On the Data tab, in the Sort & Filter group, click Sort.

    The Sort & Filter group on the Data tab

  4. In the Sort dialog box, under Column, in the Sort by or Then by box, select the column that you want to sort by a custom list.

  5. Under Order, select Custom List.

  6. In the Custom Lists dialog box, select the list that you want. Using the custom list that you created in the preceding example, click High, Medium, Low.

  7. Click OK.

  1. On the Data tab, in the Sort & Filter group, click Sort.

    The Sort & Filter group on the Data tab

  2. In the Sort dialog box, click Options.

    Click Sort to open the Sort dialog box

  3. In the Sort Options dialog box, select Case sensitive.

    In the Sort dialog box, click Options

  4. Click OK twice.

It’s most common to sort from top to bottom, but you can also sort from left to right.

Note: Tables don’t support left to right sorting. To do so, first convert the table to a range by selecting any cell in the table, and then clicking Table Tools > Convert to range.

  1. Select any cell within the range you want to sort.

  2. On the Data tab, in the Sort & Filter group, click Sort.

    The Sort & Filter group on the Data tab

  3. In the Sort dialog box, click Options.

    Click Sort to open the Sort dialog box

  4. In the Sort Options dialog box, under Orientation, click Sort left to right, and then click OK.

    In the Sort Options box, click Left to Right

  5. Under Row, in the Sort by box, select the row that you want to sort. This will generally be row 1 if you want to sort by your header row.

    Choose the row you want to sort

    Tip: If your header row is text, but you want to order columns by numbers, you can add a new row above your data range and add numbers according to the order you want them.

  6. To sort by value, select one of the options from the Order drop-down:

    1. For text values, select A to Z or Z to A.

    2. For number values, select Smallest to Largest or Largest to Smallest.

    3. For date or time values, select Oldest to Newest or Newest to Oldest.

  7. To sort by cell color, font color, or cell icon, do this:

    1. Under Sort On, select Cell Color, Font Color, or Cell Icon.

    2. Under Order select a cell color, font color, or cell icon, then select On Left or On Right.

Note: When you sort rows that are part of a worksheet outline, Excel sorts the highest-level groups (level 1) so that the detail rows or columns stay together, even if the detail rows or columns are hidden.

To sort by a part of a value in a column, such as a part number code (789-WDG-34), last name (Carol Philips), or first name (Philips, Carol), you first need to split the column into two or more columns so that the value you want to sort by is in its own column. To do this, you can use text functions to separate the parts of the cells or you can use the Convert Text to Columns Wizard. For examples and more information, see Split text into different cells and Split text among columns by using functions.

Warning: It is possible to sort a range within a range, but it is not recommended, because the result disassociates the sorted range from its original data. If you were to sort the following data as shown, the selected employees would be associated with different departments than they were before.

Example of sorting a small range within a larger one.

Fortunately, Excel will warn you if it senses you are about to attempt this:

Click Continue with the current selection

If you did not intend to sort like this, then press the Expand the selection option, otherwise select Continue with the current selection.

If the results are not what you want, click Undo Undo button.

Note: You cannot sort this way in a table.

If you get unexpected results when sorting your data, do the following:

Check to see if the values returned by a formula have changed    If the data that you have sorted contains one or more formulas, the return values of those formulas might change when the worksheet is recalculated. In this case, make sure that you reapply the sort to get up-to-date results.

Unhide rows and columns before you sort    Hidden columns are not moved when you sort columns, and hidden rows are not moved when you sort rows. Before you sort data, it’s a good idea to unhide the hidden columns and rows.

Check the locale setting    Sort orders vary by locale setting. Make sure that you have the proper locale setting in Regional Settings or Regional and Language Options in Control Panel on your computer. For information about changing the locale setting, see the Windows help system.

Enter column headings in only one row    If you need multiple line labels, wrap the text within the cell.

Turn on or off the heading row    It’s usually best to have a heading row when you sort a column to make it easier to understand the meaning of the data. By default, the value in the heading is not included in the sort operation. Occasionally, you may need to turn the heading on or off so that the value in the heading is or is not included in the sort operation. Do one of the following:

  • To exclude the first row of data from the sort because it is a column heading, on the Home tab, in the Editing group, click Sort & Filter, click Custom Sort and then select My data has headers.

  • To include the first row of data in the sort because it is not a column heading, on the Home tab, in the Editing group, click Sort & Filter, click Custom Sort, and then clear My data has headers.

If your data is formatted as an Excel table, then you can quickly sort and filter it with the filter buttons in the header row.

  1. If your data isn’t already in a table, then format it as a table. This will automatically add a filter button at the top of each table column.

  2. Click the filter button at the top of the column you want to sort on, and pick the sort order you want.

    Use Excel's Table Filter to sort in Ascending or Descending order

  3. To undo a sort, use the Undo button on the Home tab.

    Use the Undo button in Excel for the web on the Home tab to undo a previous sort

  1. Pick a cell to sort on:

    • If your data has a header row, pick the one you want to sort on, such as Population.

      Sort data with a header row

    • If your data doesn’t have a header row, pick the topmost value you want to sort on, such as 634535.

      Sort data without a header row

  2. On the Data tab, pick one of the sort methods:

    • Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.

    • Sort Descending to sort Z to A, largest to smallest, or latest to earliest date.

     Excel Sort Ascending or Descending buttons on the Data tab

Let’s say you have a table with a Department column and an Employee column. You can first sort by Department to group all the employees in the same department together, and then sort by name to put the names in alphabetical order within each department. 

Select any cell within your data range.

  1. On the Data tab, in the Sort & Filter group, click Custom Sort.

    Excel Custom Sort option from the Data tab

  2. In the Custom Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.

    Custom sort dialog with the sort by row column is selected on the column 'Name'

    Note: The Sort On menu is disabled because it’s not yet supported. For now, you can change it in the Excel desktop app.

  3. Under Order, select how you want to sort:

    • Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.

    • Sort Descending to sort Z to A, largest to smallest, or latest to earliest date.

  4. To add another column to sort by, click Add and then repeat steps five and six.

    After clicking 'Add' another sort level will appear in the list near 'Then By'

  5. To change the order in which the columns are sorted, select an entry and then click the Up or Down arrow next to the Options button.

If you have manually or conditionally formatted a range of cells or a table column by cell color or font color, you can also sort by these colors. You can also sort by an icon set that you created with conditional formatting.

  1. Select a cell in the column you want to sort

  2. On the Data tab, in the Sort & Filter group, select Custom Sort.Excel Custom Sort option from the Data tab

  3. In the Custom Sort dialog box under Columns, select the column that you want to sort.Select a column in the custom sort dialog

  4. Under Sort On, select Cell Color, Font Color or Conditional Formatting Icon.

  5. Under Order, select the order you want (what you see depends on the type of format you have). Then select a cell color, font color, or cell icon.

  6. Next, you’ll choose how you want to sort by moving the cell color, font color, or icon:

    Note: There is no default cell color, font color, or icon sort order. You must define the order that you want for each sort operation.

    • To move to the top or to the left: Select On Top for a column sort, and On Left for a row sort.

    • To move to the bottom or to the right: Select On Bottom for a column sort, and On Right for a row sort.

  7. To specify the next cell color, font color, or icon to sort by, select Add Level, and then repeat steps 1- 5.

  • Make sure that you the column in the Then by box and the selection under Order are the same.

  • Repeat for each additional cell color, font color, or icon that you want included in the sort.

  1. On the Data tab, in the Sort & Filter group, click Custom Sort.

    Excel Custom Sort options from the Data tab

  2. In the Custom Sort dialog box, click Options.

    Custom sort dialog with the option button selected

  3. In the Options menu, select Case sensitive.

    Custom sort dialog case when sensitive selected

  4. Click OK.

It’s most common to sort from top to bottom, but you can also sort from left to right.

Note: Tables don’t support left to right sorting. To do so, first convert the table to a range by selecting any cell in the table, and then clicking Table Tools > Convert to range

  1. Select any cell within the range you want to sort.

  2. On the Data tab, in the Sort & Filter group, select Custom Sort.

    Excel Custom Sort options from the Data tab

  3. In the Custom Sort dialog box, click Options.Custom sort dialog with the option button selected

  4. Under Orientation, click Sort left to right  Custom sort open 'Options' Menu and select sort left to right

  5. Under Row, in the ‘Sort by’ drop down, select the row that you want to sort. This will generally be row 1 if you want to sort by your header row.   The row drop down in custom sort dialog is open when selecting to sort left to right

  6. To sort by value, select one of the options from the Order drop-down:

    • Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.

    • Sort Descending to sort Z to A, largest to smallest, or latest to earliest date

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See also

Use the SORT and SORTBY functions to automatically sort your data.

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 More…Less

When sorting information in a worksheet, you can rearrange the data to find values quickly. You can sort a range or table of data on one or more columns of data. For example, you can sort employees —first by department, and then by last name.

How to sort in Excel?

Icon image

Select the data to sort    

Select a range of tabular data, such as A1:L5 (multiple rows and columns) or C1:C80 (a single column). The range can include the first row of headings that identify each column.

Example of selected data to sort in Excel

 

Icon image

Sort quickly and easily    

  1. Select a single cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, click A to Z command in Excel that sorts A to Z or smallest number to largest to perform an ascending sort (from A to Z, or smallest number to largest).

    Sort buttons in the Sort & Filter group on the Data tab in Excel

  3. Click Z to A command in Excel that sorts Z to A or largest number to smallest to perform a descending sort (from Z to A, or largest number to smallest).

Icon image

Sort by specifying criteria    

Use this technique to choose the column you want to sort, together with other criteria such as font or cell colors.

  1. Select a single cell anywhere in the range that you want to sort.

  2. On the Data tab, in the Sort & Filter group, click Sort to display the Sort popup window.

    Sort command in the Sort & Filter group on the Data tab in Excel

  3. In the Sort by dropdown list, select the first column on which you want to sort.

  4. In the Sort On list, choose Values, Cell Color, Font Color, or Cell Icon.

  5. In the Order list, choose the order that you want to apply to the sort operation—alphabetically or numerically, ascending or descending (that is, from A to Z (or Z to A) for text, or lower to higher, or higher to lower for numbers).

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

When it comes to Excel, here’s a good rule to live by: If you find yourself doing something manually, there’s probably an easier way.

how-to-sort-in-excel

Whether you’re trying to remove duplicates, do simple calculations, or sort your data, you can almost always find a workaround that’ll help you get it done with just a click (or two) of a button.

But if you’re not a power user, it’s easy to overlook these shortcuts. And before you know it, something as simple as organizing a list of names in alphabetical order can suck up a ton of your time.

Download 10 Excel Templates for Marketers [Free Kit]

Luckily, there is a workaround for that. In fact, there are a few different ways to use Excel’s sorting feature that you may not know about. Let’s check them out below, starting with the basics.

  1. Highlight the rows and/or columns you want sorted.
  2. Navigate to «Data» along the top and select «Sort.»
  3. If sorting by column, select the column you want to order your sheet by.
  4. If sorting by row, click «Options» and select «Sort left to right.»
  5. Choose what you’d like sorted.
  6. Choose how you’d like to order your sheet.
  7. Click «OK.»

For this first set of instructions, we’ll be using Microsoft Excel 2017 for Mac. But don’t worry — while the location of certain buttons might be different, the icons and selections you have to make are the same across most earlier versions of Excel.

1. Highlight the rows and/or columns you want sorted.

To sort a range of cells in Excel, first click and drag your cursor across your spreadsheet to highlight all of the cells you want to sort — even those rows and columns whose values you’re not actually sorting by.

For example, if you want to sort column A, but there’s data associated with column A in columns B and C, it’s important to highlight all three columns to ensure the values in Columns B and C move along with the cells you’re sorting in Column A.

In the screenshot below, we’re going to sort this sheet by the last name of Harry Potter characters. But the first name and house of each person needs to go with each last name that gets sorted, or each column will become mismatched when we finish sorting.

Highlighted spreadsheet of Harry Potter names and houses in Excel

2. Navigate to ‘Data’ along the top and select ‘Sort.’

Once all the data you want to sort is highlighted, select the «Data» tab along the top navigation bar (you can see this button on the top-right of the screenshot in the first step, above). This tab will expand a new set of options beneath it, where you can select the «Sort» button. The icon has an «A-Z» graphic on it, as you can see below, but you’ll be able to sort in more ways than just alphabetically.

Data tab in Excel, with an arrow pointing to the Sort icon

3. If sorting by column, select the column you want to order your sheet by.

When you hit the «Sort» button, shown above, a window of settings will appear. This is where you can configure what you’d like sorted and how you’d like to sort it.

If you’re sorting by a specific column, click «Column» — the leftmost dropdown menu, shown below — and select the column whose values you want to be your sorting criteria. In our case, it’ll be «Last Name.»

Sort settings window with a dropdown menu of options in the Column section

4. If sorting by row, click ‘Options’ and select ‘Sort left to right.’

If you’d rather sort by a specific row, rather than a column, click «Options» on the bottom of the window and select «Sort left to right.» Once you do this, the Sort settings window will reset and ask you to choose the specific «Row» you’d like to sort by in the leftmost dropdown (where it currently says «Column»).

This sorting system doesn’t quite make sense for our example, so we’ll stick with sorting by the «Last Name» column.

Option to Sort by left to right in Excel

5. Choose what you’d like sorted.

You don’t just have to sort by the value of each cell. In the middle column of your Sort settings window, you’ll see a dropdown menu called «Sort On.» Click it, and you can choose to sort your sheet by different characteristics of each cell in the column/row you’re sorting by. These options include cell color, font color, or any icon included in the cell.

6. Choose how you’d like to order your sheet.

In the third section of your Sort settings’ window, you’ll see a dropdown bar called «Order.» Click it to select how you’d like to order your spreadsheet.

By default, your Sort settings window will suggest sorting alphabetically (which we’ll show you shortcuts for in the next process below). But you can also sort from Z to A, as well as by a custom list. While you can create your own custom list, there are a few preset lists you can sort your data by right away. We’ll talk more about how and why you might sort by custom list in a few minutes.

To Sort by Number

If your spreadsheet includes a column of numbers, rather than letter-based values, you can also sort your sheet by these numbers. To do that, you’ll select this column in the leftmost «Columns» dropdown menu. This will change the options in the «Order» dropdown bar so that you can sort from «Smallest to Largest» or «Largest to Smallest.»

7. Click ‘OK.’

Click «OK,» in your Sort settings window, and you should see your list successfully sorted according to your desired criteria. Here’s what our Harry Potter list now looks like, organized by last name in alphabetical order:

Alphabetized spreadsheet of Harry Potter names and houses in Excel

How to Alphabetize in Excel

To alphabetize in Excel, highlight a cell in the column you want to sort by. Click the Data tab along the top navigation, and you’ll see buttons for sorting in forward or reverse alphabetical order. Clicking either button will order your sheet according to the column of the cell you first highlighted.

Sometimes you may have a list of data that has no organization whatsoever. Maybe you exported a list of your marketing contacts or blog posts. Whatever the case may be, you might want to start by alphabetizing the list — and there’s an easy way to do this that doesn’t require you to follow each step outlined above.

To Alphabetize on a Mac

  1. Select a cell in the column you want to sort.
  2. Click on the «Data» tab in your toolbar and look for the «Sort» option on the left.
  3. If the «A» is on top of the «Z,» you can just click on that button once. If the «Z» is on top of the «A,» click on the button twice. Note: When the «A» is on top of the «Z,» that means your list will be sorted in alphabetical order. However, when the «Z» is on top of the «A,» that means your list will be sorted in reverse alphabetical order.

Excel_Sorting_-_A_to_Z.gif

To Alphabetize on a PC

  1. Select a cell in the column you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see Sort options in the middle.
  3. Click on the icon above the word «Sort.» A pop-up will appear: If you have headers, make sure «My list has headers» is checked. If it is, click «Cancel.»
  4. Click on the button that has the «A» on top and the «Z» on the bottom with an arrow pointing down. That will sort your list alphabetically from «A» to «Z.» If you want to sort your list in reverse alphabetical order, click on the button that has the «Z» on top and the «A» on the bottom.

Excel_Sorting_A_to_Z_on_PC.gif

Sorting Multiple Columns

Sometimes you don’t just want to sort one column, but you want to sort two. Let’s say you want to organize all of your blog posts that you have in a list by the month they were published. First, you’d want to organize them by date, and then by the blog post title or URL.

In this example, I want to sort my list first by house, and then by last name. This would give me a list organized by each house, but also alphabetized within each house.

To Sort Multiple Columns on a Mac

  1. Click on the data in the column you want to sort.
  2. Click on the «Data» tab in your toolbar and look for the «Sort» option on the left.
  3. Click on the small arrow to the left of the «A to Z» Sort icon. Then, select «Custom Sort» from the menu.
  4. A pop-up will appear: If you have headers, make sure «My list has headers» is checked.
  5. You will see five columns. Under «Column» select the first column you want to sort from the dropdown menu. (In this case, it is «House.»)
  6. Then, click on the «+» sign at the bottom left of the pop-up. Under where it says «Column,» select «Last Name» from the dropdown.
  7. Check the «Order» column to make sure it says A to Z. Then click «OK.»
  8. Marvel at your beautiful organized list.

multiple_columns_sort_mac-1.gif

To Sort Multiple Columns on a PC

  1. Click on the data in the column you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» options in the middle.
  3. Click on the icon above the word «Sort.» You will see a pop-up appear. Make sure «My data has headers» is checked if you have column headers.
  4. You will see three columns. Under «Column» select the first column you want to sort from the dropdown menu. (In this case, it is «House.»)
  5. Then click on «Add Level» at the top left of the pop-up. Under where it says «Column» select «Last Name» from the dropdown.
  6. Check the «Order» column to make sure it says A to Z. Then click «OK.»
  7. Marvel at your beautiful organized list.

Excel_Multiple_Column_Sorting_A_to_Z_on_PC.gif

Sorting in Custom Order

Sometimes you don’t want to sort by A to Z or Z to A. Sometimes you want to sort by something else, such as months, days of the week, or some other organizational system.

In situations like this, you can create your own custom order to specify exactly the order you want the sort. (It follows a similar path to multiple columns but is slightly different.)

Let’s say we have everyone’s birthday month at Hogwarts, and we want everyone to be sorted first by Birthday Month, then by House, and then by Last Name.

To Sort in Custom Order on a Mac

  1. Click on the data in the column you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» all the way to the left.
  3. Click on the small arrow to the left of the «A to Z» Sort icon. Then, select «Custom Sort» from the menu.
  4. A pop-up will appear: If you have headers, make sure «My list has headers» is checked.
  5. You will see five columns. Under «Column,» select the first column in your spreadsheet you want to sort from the dropdown menu. In this case, it is «Birthday Month.»
  6. Under the «Order» column, click on the dropdown next to «A to Z.» Select the option for «Custom List.»
  7. You will see a couple of options (month and day). Select the month list where the months are spelled out, as that matches the data. Click «OK.»
  8. Then click on the «+» sign at the bottom left of the pop-up. Under «Column,» select «House» from the dropdown.
  9. Click on the «+» sign at the bottom left again. Under «Column,» select «Last Name» from the dropdown.
  10. Check the «Order» column to make sure «House» and «Last Name» say A to Z. Then click «OK.»
  11. Marvel at your beautiful organized list.

custom_order_Mac.gif

To Sort in Custom Order on a PC

  1. Click on the data in the column you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» options in the middle.
  3. Click on the icon above the word «Sort.» You will see a pop-up appear: If you have headers, make sure «My list has headers» is checked.
  4. You will see three columns. Under «Column,» select the first column you want to sort from the dropdown. In this case, it is «Birthday Month.»
  5. Under the «Order» column, click on the dropdown next to «A to Z.» Select the option for «Custom List.»
  6. You will see a couple of options (month and day), as well as the option to create your own custom order. Select the month list where the months are spelled out, as that matches the data. Click «OK.»
  7. Then, click on «Add Level» at the top left of the pop-up. Under «Column,» select «House» from the dropdown.
  8. Click on the «Add Level» button at the top left of the pop-up again. Under «Column,» select «Last Name» from the dropdown.
  9. Check the «Order» column to make sure «House» and «Last Name» say A to Z. Then click «OK.»
  10. Marvel at your beautiful organized list.

Excel_Custom_Sort_on_PC.gif

Sorting a Row

Sometimes your data may appear in rows instead of columns. When that happens you are still able to sort your data with a slightly different step.

To Sort a Row on a Mac

  1. Click on the data in the row you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» all the way to the left.
  3. Click on the small arrow to the left of the «A to Z» Sort icon. Then, select «Custom Sort» from the menu.
  4. A pop-up will appear: Click on «Options» at the bottom.
  5. Under «Orientation» select «Sort left to right.» Then, click «OK.»
  6. You will see five columns. Under «Row,» select the row number that you want to sort from the dropdown. (In this case, it is Row 1.) When you are done, click «OK.»

row_sorting_mac.gif

To Sort a Row on a PC

  1. Click on the data in the row you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» options in the middle.
  3. Click on the icon above the word «Sort.» You will see a pop-up appear.
  4. Click on «Options» at the bottom.
  5. Under «Orientation» select «Sort left to right.» Then, click «OK.»
  6. You will see three columns. Under «Row,» select the row number that you want to sort from the dropdown. (In this case, it is Row 1.) When you are done, click «OK.»

Row_Sorting_PC.gif

Sort Your Conditional Formatting

If you use conditional formatting to change the color of a cell, add an icon, or change the color of a font, you can actually sort by that, too.

In the example below, I’ve used colors to signify different grade ranges: If they have a 90 or above, the cell appears green. Between 80-90 is yellow. Below 80 is red. Here’s how you’d sort that information to put the top performers at the top of the list. I want to sort this information so that the top performers are at the top of the list.

To Sort Conditional Formatting on a Mac

  1. Click on the data in the row you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» all the way to the left.
  3. Click on the small arrow to the left of the «A to Z» Sort icon. Then, select «Custom Sort» from the menu.
  4. A pop-up will appear: If you have headers, make sure «My list has headers» is checked.
  5. You will see five columns. Under «Column,» select the first column you want to sort from the dropdown. In this case, it is «Grades.»
  6. Under the column that says «Sort On,» select «Cell Color».
  7. In the last column that says «Color/Icon,» select the green bar.
  8. Then click on the «+» sign at the bottom left of the pop-up. Repeat steps 5-6. Instead of selecting green under «Color/Icon,» select the yellow bar.
  9. Then click on the «+» sign at the bottom left of the pop-up. Repeat steps 5-6. Instead of selecting green under «Color/Icon,» select the red bar.
  10. Click «OK.»

sort_conditional_formatting_mac.gif

To Sort Conditional Formatting on a PC

  1. Click on the data in the row you want to sort.
  2. Click on the «Data» tab in your toolbar. You will see «Sort» options in the middle.
  3. Click on the icon above the word «Sort.» A pop-up will appear: If you have headers, make sure «My list has headers» is checked.
  4. You will see three columns. Under «Column» select the first column you want to sort from the dropdown. In this case, it is «Grades.»
  5. Under the column that says «Sort On,» select «Cell Color».
  6. In the last column that says «Order,» select the green bar.
  7. Click on «Add Level.» Repeat steps 4-5. Instead of selecting green under «Order,» select the yellow bar.
  8. Click on «Add Level» again. Repeat steps 4-5. Instead of selecting yellow under «Order,» select the red bar.
  9. Click «OK.»

conditional_formatting_pc.gif

There you have it — all the possible ways to sort in Excel. Ready to sort your next spreadsheet? Start by grabbing nine different Excel templates below, then use Excel’s sorting function to organize your data as you see fit.

excel marketing templates

excel templates

Sorting data in Excel has been made quite easy with all the in-built options.

You can easily sort your data alphabetically, based on the value in the cells, or by cell and font color.

You can also do multi-level column sorting (i.e., sorting by column A and then by column B) as well as sorting rows (from left to right).

And if that was not enough, Excel also allows you to create your own custom lists and sort based on that too (how cool is that). So you can sort data based on shirt sizes (XL, L, M, S) or responses (strongly agree, agree, disagree) or intensity (high, medium, low)

Bottom line – there are just too many sorting options you have at your disposal when working with Excel.

And in this massive in-depth tutorial, I will show you all these sorting options and some cool examples where these can be useful.

Since this a huge tutorial with many topics, I am providing a table of content below. You can click on any of the topics and it will instantly take you there.

Accessing the Sorting Options in Excel

Since sorting is such a common thing needed when working with data, Excel provides a number of ways for you to access the sorting options.

Sorting Buttons in the Ribbon

The fastest way to access sorting options is by using the sorting buttons in the ribbons.

When you click on the Data tab in the ribbon, you will see the ‘Sort & Filter’ options. The three buttons on the left in this group is for sorting the data.

Sort Option in the Data tab in Excel

The two small buttons allow you to sort your data as soon as you click on these.

Sort icons in the Data tab in Ribbon in Excel

For example, if you have a data set of names, you can just select the entire dataset and click on any of the two buttons to sort the data. The A to Z button sorts the data alphabetically lowest to highest and the Z to A button sorts the data alphabetically highest to lowest.

This buttons also work with numbers, dates or times.

Personally, I never use these buttons as these are limited in what these can do, and there are more chances of errors when using these. But in case you need a quick sort (where there are no blank cells in the dataset), these can be a fast way to do it.

Sorting Dialog Box

In the Data tab in the ribbon, there is another Sort button icon within the sorting group.

Sort Button to open the dialog box

When you click this Sort button icon, it opens the sorting dialog box (something as shown below).

Sort in Excel - Dialog box

Sorting dialog is the most complete solution for sorting in Excel. All the sorting related options can be accessed through this dialog box.

All the other methods of using sorting options are limited and don’t offer full functionality.

This is the reason I always prefer using the dialog box when I have to sort in Excel.

A major reason for my preference is that there is very less chance of you going wrong when using the dialog box. Everything is well structured and marked (unlike buttons in the ribbon where you may get confused which one to use).

In this tutorial, you’ll find me mostly using the dialog box to sort the data. This is also because some of the things I cover in certain sections (such as multi-level sorting or sorting from left-to-right) can only be done using the dialog box.

Keyboard Shortcut – If you need to sort data often in Excel, I recommend you learn the keyboard shortcut to open the sort dialog box. It’s ALT + A + S + S

Sorting Options in the Filter Menu

If you have applied filters to your dataset, you can also find the sorting options along with the filter options. A filter can be applied by selecting any cell in the dataset, clicking on the Data tab and clicking in the Filter icon.

Filter Icon in Excel Ribbon

Suppose you have a dataset as shown below and you have the filter applied.

Filter applied to a dataset

When you click on the filter icon for any column (it’s the small downward pointing triangle icon at the right of the column header cell), you’ll see some of the sorting options there as well.

Sort in Excel using Filter drop down options

Note that these sorting options change based on the data in the column. So if you have text, it will show you the option to sort from A to Z or Z to A, but if you have numbers, it will show you options to sort from largest to smallest or smallest to largest.

Right-click options

Apart from using the dialog box, using right-click is another method that I sometimes use (it’s also super fast as it only takes two clicks).

When you have a dataset that you want to sort, right-click on any cell and it will show you the sorting options.

Sort in Excel using right-click menu options

Note that you see some options that you don’t see in the ribbon or in the Filter options. While there is the usual sort by value and custom sort option (which opens the Sort dialog box), you can also see options such as Put selected Cell color/Font color/Formatting icon on the top.

I find this option quite useful as it allows me to quickly get all the colored cells (or cells with a different font color) together at the top. I often have the monthly expense data that I go through and highlight some cells manually. I can then use this option to quickly get all these cells together at the top.

Now that I have covered all the ways to access sorting options in Excel, let’s see how to use these to sort data in different scenarios.

Also read: How to Undo Sort in Excel (Revert to Original)

Sorting Data in Excel (Text, Numbers, Dates)

Caveat: Most of the times, sorting works even when you select a single cell in the dataset. But in some cases, you may end up with issues (when you have blank cells/rows/columns in your dataset). When sorting data, it’s best to select the entire data set and then sort it – just to avoid any chance of issues.

Based on the type of data you have, you can use the sorting options in Excel.

Sorting by Text

Suppose you have a dataset as shown below and you want to sort all these records based on the name of the student in alphabetical order.

Student Name dataset for sorting

Below are the steps to sort this text data in alphabetical order:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.Sort Button to open the dialog box
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.Make Sure My Data has headers option is selected
  5. In the ‘Sort by’ drop-down, select ‘Name’Select Name in Sort by drop down
  6. In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selectedSelect Cell Values in Sort on drop down
  7. In the Order drop-down, select A-ZSelect A to Z in Sort Order dialog box
  8. Click OK.

The above steps would sort the entire dataset and give the result as shown below.

Student name data sorted alphabetically

Why not just use the buttons in the ribbon?

The above method of sorting data in Excel may look like a lot of steps, as compared to just clicking the sort icon in the ribbon.

And this is true.

The above method is longer, but there is no chance of any error.

When you use the sort buttons in the ribbon, there are a few things that can go wrong (and this could be hard to spot when you have a large data set.

While I discuss the drawbacks of using the buttons later in this tutorial, let me quickly show you what can go wrong.

In the below example, since Excel cannot recognize that there is a header row, it sorts the entire dataset, including the header.

Sort Icon Button Issue - Column Header not recognized

This issue is avoided with the sort dialog box as it explicitly gives you the option to specify whether your data has headers or not.

Since using the Sort dialog box eliminates chances of errors, I recommend you use it instead of all the other sorting methods in Excel

Sorting by Numbers

Now, I am assuming you have already gotten a hang of how text sorting works (covered above this section).

The other types of sorting (such as based on numbers or dates or color) is going to use almost the same steps with minor variations.

Suppose you have a dataset as shown below and you want to sort this data based on the marks scored by each student.

Sort by Student Score by Numbers - Dataset

Below are the steps to sort this data based on numbers:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. In the ‘Sort by’ drop-down, select ‘Name’
  6. In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selected
  7. In the Order drop-down, select ‘Largest to Smallest’
  8. Click OK.

The above steps would sort the entire dataset and give the result as shown below.

Student Score sorted from largest to smallest

Sorting by Date/Time

While the date and time may look different, they are nothing but numbers.

For example, in Excel, the number 44196 would be the date value for 31 December 2020. You can format this number to look like a date, but in the backend in Excel, it still remains a number.

This also allows you to treat dates as numbers. So you can add 10 to a cell with date, and it will give you the number for the date 10 days later.

And the same goes for the time in Excel.

For example, the number 44196.125 represents 3 AM on 31st December 2020. While the integer part of the number represents a full day, the decimal part would give you the time.

And since both date and time are numbers, you can sort these like numbers.

Suppose you have a dataset as shown below and you want to sort this data based on the project submission date.

Dataset to Sort by Dates in Excel

Below are the steps to sort this data based on the dates:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. In the ‘Sort by’ drop-down, select ‘Submission Date’
  6. In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selected
  7. In the Order drop-down, select ‘Oldest to Newest’
  8. Click OK.

The above steps would sort the entire dataset and give the result as shown below.

Data sorted by dates - Result

Note that while date and time are numbers, Excel still recognized that these are different in the way it’s displayed. So when you sort by date, it shows ‘Oldest to Newest’ and ‘Newest to Oldest’ sorting criteria, but when you use numbers, it shows ‘Largest to Smallest’ or ‘Smallest to Largest’. Such small things that makes Excel an awesome spreadsheet tool (PS: Google Sheets doesn’t show so much detail, just the bland sort by A-Z or Z-A)

Sorting by Cell Color / Font Color

This option is amazing and I use it all the time (maybe a tad bit too much).

I often have data sets that I analyze manually and highlight cells while I am doing it. For example, I was going through a list of articles on this blog (which I have in an Excel sheet) and I highlighted the ones which I needed to improve.

And once I am done, I can quickly sort this data based on the cell colors. This helps me in getting all these highlighted cells/rows together at the top.

And to add to the awesomeness, you can sort based on multiple colors. So if I highlight cells with article names which need immediate attention in red and some which can be dealt with later with yellow, I can sort the data to show all the red rows first followed by the yellow.

If you’re interested in learning more, I recently wrote this article on sorting based on multiple colors. In this section, I will quickly show you how to sort based on one color only

Suppose you have a dataset as shown below and you want to sort by color and get all the red cells at the top.

Sort Data by Color in Excel - Dataset

Below are the steps to sort by color:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. In the ‘Sort by’ drop-down, select ‘Submission Date’ (or whatever column where you have the colored cells).Since in this example we have colored cells in all the columns, you can choose any.
  6. In the ‘Sort On’ drop-down, select ‘Cell Color’.
  7. In the Order drop-down, select the color with which you want to sort. In case you have multiple cell colors in the dataset, it will show you all those colors hereSelect color by which you want to sort the data
  8. In the last drop-down, select ‘On Top’. This is where you specify whether you want the colored cells to be on the top of the dataset or at the bottom.
  9. Click OK.

The above steps would sort your dataset by color and you will get the result as shown below.

Sort Data by color - result

Just as we have sorted this data based on the cell color, you can also do it based on the font color and conditional formatting icon.

Multiple Level Data Sorting

In reality, datasets are rarely as simple as the one that I am using in this tutorial.

Yours may extend to thousands of rows and hundreds of columns.

And when you have datasets so big, there is also a need for more data slice and dice. Multiple level data sorting is one of the things you may need when you have a large data set.

Multiple level data sorting means that you can sort the dataset based on values in one column and then sort it again based on values in another column(s).

For example, suppose you have the dataset as shown below and you want to sort this data based on two criteria:

  1. The region
  2. The sales

Multi-level sorting in Excel - Dataset

The output of this sorting based on the above two criteria will give you a dataset as shown below.

In the above example, we have the data first sorted by the regions and then within each region, the data is further sorted by the sales value.

This quickly allows us to see which sales reps are doing great in each region or which ones are doing poorly.

Below are the steps to sort the data based on multiple columns:

  1. Select the entire data set that you want to sort.
  2. Click the Data tab.
  3. Click on the Sort Icon (the one shown below). This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. In the Sort Dialogue box, make the following selections
    • Sort by (Column): Region (this is the first level of sorting)
    • Sort On: Cell Values
    • Order: A to Z
  6. Click on Add Level (this will add another level of sorting options).Click on Add Level to add another level of sorting for the dataset
  7. In the second level of sorting, make the following selections:
    • Then by (Column): Sales
    • Sort On: Values
    • Order: Largest to SmallestSecond Level sorting criteria in dialog box
  8. Click OK

Pro Tip: The Sort dialog box has a feature to ‘Copy Level’. This quickly copies the selected sorting level and then you can easily modify it. It’s good to know feature and may end up saving you time in case you have to sort based on multiple columns.

Below is a video where I show how to do a multi-level sorting in Excel:

Sorting Based on a Custom List

While Excel already has some common sorting criteria (such as sorting alphabetically with text, smallest to largest or largest to smallest with numbers, oldest to newest or newest to oldest with dates), it may not be enough.

To give you an example, suppose I have the following dataset:

Dataset to sort based on region

Now, if I sort it based on the region alphabetically, I have two options – A to Z or Z to A. Below is what I get when I sort this data alphabetically from A to Z using the region column.

Sorting Region Data Alphabetically A to Z

But what if I want this sort order to be East, West, North, South?

You, of course, can rearrange the data after sorting, but that’s not the efficient way to do this.

The right way to do this would be using custom lists.

A custom list is a list that Excel allows you to create and then use just like the inbuilt lists (such as month names or weekday names). Once you have created a custom list, you can use it in features such as data sorting or fill handle.

Some example where custom lists can be useful include:

  • Sorting the data based on region/city name
  • Sorting based on T-shirt sizes – Small, Medium, Large, Extra Large
  • Sorting based on survey responses – Strongly Agree, Agree, Neutral, Disagree
  • Sorting based on probability – high, medium, low

The first step in trying to sort based on the custom criteria is to create the custom list.

Steps to create a custom list in Excel:

  1. Click the File tabClick the File Tab
  2. Click on OptionsClick on Options
  3. In the Excel Options Dialogue Box, select ‘Advanced’ from the list in the left pane.Click on Advanced in the left pane
  4. Within Advanced selected, scroll down and select ‘Edit Custom List’.Click on Edit Custom List
  5. In the Custom Lists dialogue box, type your criteria in the box titled List Entries. Type your criteria separated by comma (East, West, North, South) [you can also import your criteria if you have it listed].Specify the custom sort order criteria
  6. Click Add
  7. Click OK

Once you have completed the above steps, Excel will create and store a custom list that you can use for sorting data.

Note that the order of the items in the custom list is what determines how your list will be sorted.

When you create a custom list in one Excel workbook, it becomes available to all the workbooks in your system. So you only have to create it once and can reuse it in al workbooks.

Steps to sort using a custom list

Suppose you have the dataset as shown below and you want to sort it based on the regions (the sort order being East, West, North, and South)

Since we have already created a custom list, we can use it to sort our data.

Here are the steps to sort a dataset using a custom list:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. In the ‘Sort by’ drop-down, select ‘Region’ (or whatever column where you have the colored cells)
  6. In the ‘Sort On’ drop-down, select ‘Cell Values’.
  7. In the Order drop-down, select ‘Custom List’. As soon as you click on it, it will open the Custom Lists dialog box.Click on Custom List and the Sort Order
  8. In the Custom Lists dialog box, select the custom list you have already created from the left pane.Select the custom sort criteria
  9. Click OK. Once you do this, you will see the custom sort criteria in the sort order drop-down fieldCustom Sort criteria becomes available as the sort order
  10. Click OK.

The above steps will sort your dataset based on the custom sort criteria.

Sorting region based on custom criteria - resulting data

Note: You don’t have to create a custom list before-hand to sort the data based on it. You can also create it while you’re in the Sort dialog box. When you click on Custom List (in step 7 above), it opens the custom list dialog box. You can create a custom list there as well.

Custom lists are not case sensitive. In case you want to do a case-sensitive sorting, refer to this example.

Also read: How to Sort by Length in Excel? Easy Formulas!

Sorting from Left to Right

While in most cases you’ll likely sort based on the column values, sometimes, you may also have a need to sort based on the row values.

For example, in the below dataset, I want to sort it based on the values in the Region row.

Sort data left to right in Excel - Dataset

Although this type of data structure is not as common as the columnar data, I have still seen a lot of people working with this kind of construct.

Excel has an in-built functionality that allows you to sort from left to right.

Below are the steps to sort this data from left to right:

  1. Select the entire dataset (except the headers)
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, click on Options.Click on Option to sort left to right in Excel
  5. In the Sort Options dialog box, select ‘Sort left to right’Select Sort Left to Right
  6. Click OK.
  7. In the ‘Sort By’ drop-down, select Row 1. By doing this, we are specifying that the sort needs to be done based on the values in Row 1
  8. In the ‘Sort On’ drop-down, select ‘Cell Values’.
  9. In the Order drop-down, select A-Z (you can also use custom sort list if you want)
  10. Click OK.

The above steps would sort the data left to right based on Row 1 values.

Left to Right Sort Result

Excel doesn’t recognize (or even allow you to specify) the headers when sorting from left to right. So you need to make sure your header cells are not selected when sorting the data. If you select headers cells as well, these will be sorted based on the value in it.

Note: Another way of sorting the data from right to left could be to transpose the data and get it in a columnar form. Once you have it, you can use any of the sorting methods covered so far. Once the sorting is done, you can then copy the resulting data and paste it as transposed data.

Below is a video where I show how to sort data from left to right in Excel

Case Sensitive Sorting in Excel

So far, in all the example above, the sorting has been case independent.

But what if you want to make the sorting case-sensitive.

Thankfully, Excel allows you to specify whether you want the sorting to be case-sensitive or not.

Note: While most of the times you don’t need to worry about case-sensitive sorting, this may be helpful when you get your data from a database such as Salesforce or you manually collate the data and have different people enter the same text in different cases. Having a case sensitive sort may help you keep all the records by the same person/database together.

Suppose you have a dataset as shown below and you want to sort this data based on the region column:

Case Sensitive sort in Excel - dataset

Below are the steps to sort data alphabetically as well as make it case sensitive:

  1. Select the entire dataset
  2. Click the Data tab
  3. Click the Sort icon. This will open the Sort dialog box.
  4. In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
  5. Click the Options buttonClick the Option button in the Sort dialog box
  6. In the Sort Options dialog box, check the ‘Case sensitive’ optionCheck the case sensitive option
  7. Click OK.
  8. In the ‘Sort by’ drop-down, select ‘Region’
  9. In the ‘Sort On’ drop-down, select ‘Cell Values’.
  10. In the order drop-down, select A to Z
  11. Click OK.

The above steps would not only sort the data alphabetically based on the region, but also make it case-sensitive.

You’ll get the resulting data as shown below:

Case Sensitive Sort in Excel - Result

When you sort from A to Z, lower case text is placed above the upper case text.

Getting the Original Sort Order

Often when sorting data in Excel, you may want to go back to the earlier or the original sort order and start afresh,

While you can use the undo functionality in Excel (using Control Z) to go back one step at a time, it may be confusing if you have already done multiple things after sorting the data.

Also, undo works only till you have the workbook open, but when you save and close and it and open it later, you won’t be able to go back to the original sort order.

Here are two simple ways to make sure you don’t lose the original sort order and get it back even after sorting the data:

  1. Make a copy of the original dataset. This is something I recommend you do even if you don’t need the original sort order. You can have a workbook with all the data and then simply create a copy of the workbook and work on the copy. When I am working on critical datasets, I make a copy every day (with the date or version number as a part of the workbook name).
  2. Add a column with a series of number. This series of numbers get all mixed up when you sort the data, but in case you want to go back to the original data, you can sort based in this series of numbers.

In this section, let me quickly show you what mean by adding a series and using it to get original sort order back.

Suppose you have a dataset as shown below:

Data set for sorting - without helper column

To make sure you have a way to get back this data after sorting it, add a helper column and have a series of numbers in it (as shown below).

Dataset with helper column

Here is a tutorial with different ways to add a column with numbers quickly

When you have the helper column in place, make sure you include it while sorting this dataset.

Suppose I sort this data based on the region and end up getting the data as shown below:

Helper column also get sorted when you sort the data

Now, if I want to go back to the original dataset, I can simply sort this data again, but based on the helper column (from low to high).

Simple.. isn’t it?

In case you don’t want the helper column to show, you can either hide it or create a backup and then delete it.

Some Common Issues While Sorting Data in Excel

At the beginning of this article, I showed you different ways to sort data in Excel (including sort buttons in the ribbon, right-click options, filter option, and the sort dialog box).

And to reiterate, using the sort dialog box minimizes the chances or any issues or error that may arise.

Now, let me show you what can go wrong when you use the sort button from the ribbon (the ones shown below)

Not Identifying the Column Headers

Suppose you have a dataset as shown below:

This looks like a decently formatted data set with headers clearly formatted with cell color and bold font.

So when you sort this data based on the names (using the sort buttons in the ribbon), you would expect the header to remain at the top and rest of the data to get sorted.

But what happens when you do it – the header is also considered as normal data and gets sorted (as shown below).

Sort Icon Button Issue - Column Header not recognized

While Excel is smart enough to recognize headers, in this example, it failed to do so. When using the sort icon buttons in the ribbon, there was no way for you to manually specify that this data has headers.

Note: This issue occurs when I have the dataset and I add and format the headers and sort it. Normally, Excel would be smart enough to identify that there are headers in a dataset (especially when the data type of the header and the data in the column is different). But in this case, it failed to do so when I added the header and sorted right away. If I save this workbook, close it and reopen it, Excel somehow manages to identify the first row and header.

While this may not be an issue in most cases, there is still a chance when you use the sort icons in the ribbon, Using a dialog box eliminates this issue as you can specify that you have headers.

Not Identifying Blank Rows/Columns

This sorting issue is a little more complex – and a lot more common than you would imagine.

Suppose you have a dataset as shown below. Note that row number 6 is hidden (and it’s a blank row).

Row is blank and is hidden in the dataset

Now, if I select any cell in the first four rows of the data (the ones above the hidden blank row) and sort this data using the sort icon buttons, it would only sort the first four records on the data set (row 2 to 5). Similarly, if I select any cell in the dataset below the hidden blank row, it will only sort the last seven rows.

Issue with blank hidden row when sorting

And unless you’re looking for it specifically, you’re likely to miss this horrible error.

How to make sure you don’t end up making this sorting error?

To make sure you don’t fall prey to this issue, you need to check your dataset before sorting it.

Select the entire dataset before sorting the data.

You can do that by selecting any cell in the dataset and then using the keyboard shortcut – Control + A.

If there are blank rows/columns in your dataset, the entire dataset won’t get selected. You can identify this by quickly scanning the outline of the selection.

If you see that there is some data left outside the selection, you can manually select it.

To make sure this issue is avoided, it’s best to first unhide all hidden rows and columns and then proceed to sort the data by selecting the entire data set or by first deleting the blank rows.

Partial Sorting (Based on the Last Name)

Sometimes, you may have a dataset that you want to sort based on part of the text.

For example, suppose I have the dataset as shown below and I want to sort this data based on the last name.

Sort Data based on last name - dataset

To do this, I need to separate this data so that I have only the last names in one column. When I have it, I can use that column to sort the data.

Below is a formula that can give me the last name:

=RIGHT(B2,LEN(B2)-FIND(" ",B2))

This will give you a result as shown below.

Formula to get the last name

Now you can use the Last Name column to sort this data.

Once done, you can delete the last name column or hide it.

Note that the above formula works when you have names that has first and last name only and have no double spaces in between. In case you have names data that is different, you will have to adjust the formula. You can also use Text to Column to quickly split the names based on space character as the delimiter.

This is just one example of sorting based on partial data. Other examples may include sorting based on cities in an address or employee ID based on department codes.

Also, in case the text based on which you need to sort is at the beginning of the text, you can use the normal sort feature only.

Other Sorting Examples (Using Formula and VBA)

So far in this tutorial, I have covered the examples where we have used the in-built sorting functionality in Excel.

Automatically Sorting Using a Formula

When you use the in-built sort functionality and then make any change in the data set, you need to sort it again. The sort functionality is not dynamic.

In case you want to get a dataset that sorts automatically whenever there is any change, you can use the formulas to do it.

Note that to do this, you need to keep the original dataset and the sorted dataset separate (as shown below)

I have a detailed tutorial where I cover how to sort alphabetically using formulas. It shows two methods to do this – using helper columns and using an array formula.

Excel has also introduced the SORT dynamic array formula which can easily do this (without helper column or a complicated array formula). But since this is quite new, you may not have access to it in your version of Excel.

Sorting Using VBA

And finally, if you want to bypass all the sorting dialog box or other sorting options, you can use VBA to sort your data.

In the below example, I have a dataset that sorts the data when I double click on the column header. This makes it easy to sort and can be used in dashboards to make it more user-friendly.

Here is a detailed tutorial where I cover how to sort data using VBA and create something as shown above.

I have tried to cover a lot of examples to show you different ways you can sort data in Excel and all the things you need to keep in mind when doing it.

Hope you found this tutorial useful.

You May Also Like the following Excel Tutorials:

  • Search and Highlight Data Using Conditional Formatting
  • How to Sort Worksheets in Excel using VBA
  • How to Create a Data Entry Form in Excel
  • How to Compare Two Columns in Excel
  • Excel TRIM Function to Remove Spaces and Clean Data
  • Flip Data in Excel | Reverse Order of Data in Column/Row
  • How to Shuffle a List of Items/Names in Excel? 2 Easy Formulas!

Содержание

  1. Sort data using a custom list
  2. Sort by days of the week or months of the year with a built-in custom list
  3. Create your own custom list
  4. Need more help?
  5. Quick start: Sort data in an Excel worksheet
  6. How to sort in Excel?
  7. Sort data in a table
  8. Sort the table
  9. Need more help?
  10. Sort Data in Excel & Avoid Problems
  11. Avoid Sorting Trouble: Check Your Data
  12. 1) Make a Backup of Your Data
  13. 2) Check Your Data
  14. How to Check For Blank Rows or Columns
  15. 3) Fix Blank Rows and Columns
  16. Quick Sort With Sort Buttons
  17. Check the Results
  18. Sort Buttons on Quick Access Toolbar
  19. Sort Two or More Columns
  20. Sort in a Custom Order
  21. Sort in a Custom Order
  22. Sorting a Row
  23. Sorting a Row
  24. Sort Data by Cell Icon
  25. Sort by Selected Cell Icon
  26. Sort With Heading Drop Down List
  27. VLOOKUP Sorting Problem
  28. Sort Sample Workbook

Sort data using a custom list

With built-in custom lists, you can sort data—either by days of the week or months of the year. Optionally, you can create your own custom lists to sort by any other characteristic that doesn’t sort well alphabetically—such as high, medium, and low—or S, M, L, XL.

With custom lists, you could sort this worksheet either by Delivery month or by Priority.

Sort by days of the week or months of the year with a built-in custom list

Follow these steps:

Select the columns to sort.

Note: For the best results, each column should have a heading.

In the ribbon, click Data > Sort.

In the Sort popup window, in the Sort by drop-down, choose the column on which you need to sort.

For example, if you want to re-sort the previous example by delivery date, under Sort by, choose delivery.

From the Order drop-down, select Custom List.

In the Custom Lists box, select the list that you want, and then click OK to sort the worksheet.

Create your own custom list

Follow these steps to create your own custom list for sorting:

In a column of a worksheet, type the values to sort by. Arrange them in the order that you want to define the sort order—from top to bottom. For example:

Select all of the cells in that list, and then click File > Options > Advanced.

Scroll way down to the General section and click Edit Custom Lists.

In the Custom Lists box, click Import.

Tip: For a short list—such as High, Medium, and Low, it may be faster to enter it directly into the List entries box in the Custom Lists box.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Quick start: Sort data in an Excel worksheet

When sorting information in a worksheet, you can rearrange the data to find values quickly. You can sort a range or table of data on one or more columns of data. For example, you can sort employees —first by department, and then by last name.

How to sort in Excel?

Select the data to sort

Select a range of tabular data, such as A1:L5 (multiple rows and columns) or C1:C80 (a single column). The range can include the first row of headings that identify each column.

Sort quickly and easily

Select a single cell in the column you want to sort.

On the Data tab, in the Sort & Filter group, click to perform an ascending sort (from A to Z, or smallest number to largest).

Click to perform a descending sort (from Z to A, or largest number to smallest).

Sort by specifying criteria

Use this technique to choose the column you want to sort, together with other criteria such as font or cell colors.

Select a single cell anywhere in the range that you want to sort.

On the Data tab, in the Sort & Filter group, click Sort to display the Sort popup window.

In the Sort by dropdown list, select the first column on which you want to sort.

In the Sort On list, choose Values, Cell Color, Font Color, or Cell Icon.

In the Order list, choose the order that you want to apply to the sort operation—alphabetically or numerically, ascending or descending (that is, from A to Z (or Z to A) for text, or lower to higher, or higher to lower for numbers).

Источник

Sort data in a table

Sorting is one of the most common tools for data management. In Excel, you can sort your table by one or more columns, by ascending or descending order, or do a custom sort.

Sort the table

Select a cell within the data.

Select Home > Sort & Filter.

Or, select Data > Sort.

Select an option:

Sort A to Z — sorts the selected column in an ascending order.

Sort Z to A — sorts the selected column in a descending order.

Custom Sort — sorts data in multiple columns by applying different sort criteria.

Here’s how to do a custom sort:

Select Custom Sort.

Select Add Level.

For Column, select the column you want to Sort by from the drop-down, and then select the second column you Then by want to sort. For example, Sort by Department and Then by Status.

For Sort On, select Values.

For Order, select an option, like A to Z, Smallest to Largest, or Largest to Smallest.

For each additional column that you want to sort by, repeat steps 2-5.

Note: To delete a level, select Delete Level.

Check the My data has headers checkbox, if your data has a header row.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Sort Data in Excel & Avoid Problems

How to sort in Excel list by row or column. Tips show how to avoid painful mistakes when sorting your spreadsheets. How to sort multiple columns, rows, or sort in custom order. Videos, and Excel workbook.

Avoid Sorting Trouble: Check Your Data

1) Make a Backup of Your Data

Be sure to make a backup copy of your Microsoft Excel file, before you start sorting the data. Then, you can go back to the saved version, if anything goes wrong.

Tip: For a quick and easy backup copy, get my free Excel Backup tool. This tool makes a backup copy in the current folder, and does NOT affect the active workbook. The backup tool is in xlam format, so it’s easy to install on your computer — just like any other Excel file.

2) Check Your Data

Before you sort data in Excel, be sure there are no blank rows or columns within the data range on the worksheet. The steps below show how to do that.

Why is it important to check your data?

  • If there is a blank row or blank column in the data, part of the data might be sorted, while other data is not sorted.
  • You could end up with names and phone numbers that don’t match, or orders with the wrong customer address.
  • Check for formulas that include an sheet name, in references to cells on the current sheet. For a formula example, see the VLOOKUP Sorting Problem below.

How to Check For Blank Rows or Columns

To help prevent sorting problems, follow these steps before you sort Excel data:

  1. Select one cell in the column you want to sort.
  2. Press Ctrl + A, to select the entire region.
  3. Check the selected area, to make sure that all the data is included.
    • For example, in the screen shot below, hidden column E is blank
    • After pressing Ctrl+A, columns F, G (hidden), H and I are not selected.

3) Fix Blank Rows and Columns

  1. If some of the data was NOT selected, find the blank rows or columns
    • You might need to unhide rows or columns, to find the blank ones
  2. After you find a blank row or column:
    • If the blank row or column is not needed, delete it
    • If the blank row or column IS needed, enter at least one item in the row or column.
      • For example, type an «x» in a column heading, as a placeholder.

Then, after you fix any blank columns or rows:

  • Press Ctrl + A again, to see if the entire region is selected.
    • If not, look for other blank rows or columns, and delete or fill them
    • If the entire region IS selected, the data can be safely sorted

Quick Sort With Sort Buttons

In Excel, you can quickly sort your data by using the A-Z (ascending order) and Z-A (descending order) buttons on the Ribbon’s Data tab.

Follow these steps to sort with the Quick Sort command buttons:

  1. Select one cell in the column you want to sort.
  2. On the Excel Ribbon, click the Data tab.
  3. Click Sort A to Z (smallest to largest) or Sort Z to A (largest to smallest)

Check the Results

Immediately after sorting, and before you do anything else:

  • Check the sorted data, to see if the data has been sorted correctly.

If anything looks incorrect, or out of order:

  • Immediately click the Undo button on the toolbar

If you sort frequently, you can add the Sort buttons to your Quick Access Toolbar (QAT). That makes it even easier to do a quick sort in Excel. There are «how to» steps on the Quick Access Toolbar page. that show how to add buttons.

Then, to use those Sort icons, follow the steps in the Quick Sort with A-Z Buttons section, but use the QAT buttons instead.

Sort Two or More Columns

If you want to sort 2 or more columns in an Excel table, use the Sort dialog box, where you can set up a multi-level sort.

In this example, the table contains personal data, and it will be sorted by 3 columns:

  1. First, by Gender
  2. Next, by State
  3. Finally, by Birth Year

Follow these steps to safely sort the data set by the 3 columns:

  1. Select all the cells in the list.
    This is the safest approach to sorting. In most cases, you can select one cell and Excel will correctly detect the rest of the list — but it’s not 100% certain. Some of the data may be missed.
  2. On the Excel Ribbon, click the Data tab.
  3. In the Sort & Filter group, click the Sort button.

  • Click the Add Level button, to add the first sorting level.
  • From the Sort by dropdown, select the first column you want to sort. In this example, Gender will be the first column sorted.

    Note: If the dropdown is showing Column letters instead of headings, add a check mark to My data has headers.

    From the Sort On drop down, select the option that you want. We’re sorting on the values in the Gender column, so leave the default setting of Values.

    Next, from the Order drop down, select one of the options. The list of Order options will depend on what you selected in the Sort On column. Because we selected values, the Order options are A to Z, Z to A and Custom List. We’ll select A to Z.

    If you are sorting on multiple columns, click the Add Level button, to add the next level, and select options from its drop down boxes.

    Here we have selected Gender, State and BirthYr as the sort fields, and all are sorted on Values. Because the BirthYr column contains only numbers, its Order options are slightly different from the text column options.

  • After you have selected all the Sort levels, and their options, click OK.
  • The data will be sorted in the order that you specified. In the screen shot below:

    • Gender column is sorted first, so all the female names are at the top.
    • Next, the State column is sorted, so females from Alabama are at the top of the list.
    • Finally, the BirthYr is sorted, with the earliest birth years at the top of each state.

    Sort in a Custom Order

    In the Sort dialog box, or on the Excel Ribbon, you can select a sort order, such as A to Z, or Largest to Smallest. In addition to these standard options, you can sort in a custom order, such as month order, or weekday order. In this example, we’ll sort a column with weekday names, using the Excel Ribbon command.

    Watch the steps for doing a custom sort in the Sort Custom Order video, or follow the written instructions, below the video.

    Sort in a Custom Order

    In the Sort dialog box, or on the Excel Ribbon, you can select a sort order, such as A to Z, or Largest to Smallest. In addition to these standard options, you can sort in a custom order, such as month order, or weekday order. In this example, we’ll sort a column with weekday names, using the Excel Ribbon comman

    To sort in a custom order, follow these steps:

    1. Select one cell in the column you want to sort.
    2. Press Ctrl + A, to select the entire region.
    3. Check the selected area, to make sure that all the data is included.
    4. On the Excel Ribbon, click the Home tab
    5. In the Editing group, click the arrow on Sort & Filter.
    6. Click Custom Order.

  • In the Sort dialog box, select the Day column in the Sort By box.
  • From the Order drop down, select Custom List.

    In the Custom dialog box, select a custom list and then click OK, twice, to close the dialog boxes.

    The Day column is sorted in weekday order, instead of alphabetical order, so Sunday appears at the top of the list.

    Sorting a Row

    Instead of sorting your data by columns, you can sort the data by row. In this example, we’ll sort a table of monthly sales, so the month with the largest sales total is at the left. To do this, we’ll use a right-click popup menu.

    You can see the steps in this short Sort by Row video, and read the detailed instructions below.

    Sorting a Row

    Instead of sorting your data by columns, you can sort the data by row. In this example, we’ll sort a table of monthly sales, so the month with the largest sales total is at the left. To do this, we’ll use a right-click popup menu.

    To sort by a row, follow these steps:

    1. Select one cell in the row you want to sort.
    2. Press Ctrl + A, to select the entire region.
    3. Check the selected area, to make sure that all the data is included.
    4. Right-click a cell in the row that you want to sort
    5. In the popup menu, click Sort, then click Custom Sort.

  • In the Sort dialog box, select the Day column in the Sort By box.
  • From the Order drop down, select Custom List.
  • At the top of the Sort dialog box, click the Options button.

    In the Sort Options dialog box, under Orientation, select Sort Left to Right.

  • Click OK, to close the Options dialog box.
  • From the Sort By drop down, select the row that you want to sort.
  • There are no headings available, so select the correct Row number.

  • Select the Sort On, and the Order options, then click OK.
  • The data is sorted by the values in the selected row.

    Sort Data by Cell Icon

    Watch this short video to see the steps for adding cell icons, and sorting by the selected cell’s icon. There are written steps below the video.

    When you create a named Excel table, or apply an AutoFilter to a list, each heading cell gets a drop down arrow. Click that arrow, and you’ll see a variety of sorting and filtering options for the data.

    If you add conditional formatting icons to one of the columns, you can also sort by those icons. In the screen shot below, Traffic light icons are being added to the Quantity column.

    Sort by Selected Cell Icon

    After adding icons, the quickest way to sort by a specific icon is:

    1. Right-click on a cell that contains the icon you want at the top of the list
    2. In the pop-up menu, click Sort
    3. Click Put Selected Cell Icon On Top

    The list is sorted, to move all items with the selected icon to the top of the list.

    Other items are not sorted, and the items that were moved to the top of the list are left in their original order, within that group.

    Sort With Heading Drop Down List

    After you have added cell icons, you can also sort by icon from the drop down list in the heading.

    1. Click the drop down arrow in the heading cell
    2. Click Sort by Color
    3. Click on an icon, to move it to the top of the list

    VLOOKUP Sorting Problem

    A VLOOKUP formula may return the correct results at first, but then shows incorrect results if the list of items is sorted. This can occur if the reference to the Lookup value includes a sheet name. For example:

    =VLOOKUP(‘Order Form’!B5, Products!$B$2:$C$6,2,FALSE)

    NOTE: This problem can occur with other functions too, such as an INDEX/MATCH lookup formula.

    Watch this video to see the steps for fixing the problem, and download the VLOOKUP Sorting problem sample file to follow along. The written instructions are on the How to Use Excel VLOOKUP — Examples page.

    Sort Sample Workbook

    To try the sorting techniques, get the Sort sample workbook. The file is in xlsx file format, and is zipped. It does not contain any macros.

    Источник

    Microsoft Excel offers two widely used features: sorting and filtering. They are frequently used in data analysis to set up, organize, and subset your data according to particular criteria. You will discover how to sort data in Excel in this article. You will also get knowledge of data filtering.

    What is Sorting in Excel?

    Sorting is the process of arranging the strings or integers so that they can be placed in ascending or descending order. A text column can be sorted alphabetically (A-Z or Z-A). A number column can be sorted either from largest to smallest or from smallest to largest. A date and time column can alternatively be sorted from oldest to newest or from newest to oldest. Excel also has the option of sorting using a custom list or formats like cell color, font color, or icon set.

    In this article, we will look into how we can do Sorting in Excel. 

    Sorting a Single Column in Excel

    Consider the Employee dataset depicted below. It has information about the employees, the Job Title, Department, Gender, and so on.

    excel sorting

    Employee Dataset

    Let’s sort the data based on the Annual Salary of each Employee in descending order.

    • You can choose the data and the shortcut key Ctrl + Shift + L to sort just one column.
    • Select the List Annual Salary column’s downward pointing arrow. From largest to smallest, choose.

    sorting in excel

    Sorting Employee Dataset

    Sorting by Multiple Columns

    Most often, only one column needs to be sorted. However, there can be times when you need to sort across many columns. Data can be sorted by several columns using advanced sorting methods.

    Let’s sort the Employee dataset in ascending order of Annual Salary and descending order of Age.

    • Step 1: Select the dataset > Click on the Sort option in the Data tab
    • Step 2: To sort, select the Annual Salary column
    • Step 3: Select Values under Sort On
    • Step 4: Under Order, choose Smallest to Largest/A-Z
    • Step 5: Select Add Level, and choose the Age column
    • Step 6: Now Sort on Cell Values and Order it by Largest to Smallest/Z-A

     Multiple Columns Sorting in excel

     Multiple Columns Sorting 

    Sorting Strings

    Step 1: Formatting data for sorting.

    sorting strings excel

    Step 2: Converting data from unsorted to sorted order in ascending order. First, highlight the data which we want to sort.

    excel string sort

    Step 3: Then, click to Data on the Ribbon. In the Sort & Filter group, click Sort.

    excel string sort formula

    Step 4:- In the Sort box, select A to Z in order to sort the data in ascending order, then click Ok.

    sorting excel data

    Now, data are sorted in ascending order.

    excel data sorted

    Step 5: Now, if we want to sort in descending then we have to select Z to A in order to sort the data in descending order, then click OK.

    sorting descending order excel

    Now, data are sorted in descending order.

    sorted descending order excel

    Sorting Integers

    Step 1: Formatting data for sorting.

    excel sorting integers

    Step 2: Converting data from unsorted to sorted order in ascending order.

    First, highlight the data which we want to sort.

    sorting integer data excel

    Step 3: Then, click to Data on the Ribbon. In the Sort & Filter group, click Sort.

    how to do sorting in excel sheet

    Step 4: In the Sort box, select Smallest to Largest in Order to sort the data in ascending order, then click Ok.

    sorting integers in excel sheet

    Now, data are sorted in ascending order.

    sorting in ascending order excel

    Step 5: Now, if we want to sort in descending then we have to select Largest to Smallest in Order to sort the data in descending order, then click Ok.

    ascending order sorting excel

    Now, data are sorted in descending order.

    excel integers sorting

    Custom Sorting

    You can create your own custom order in Excel by using custom sorting. Data that cannot be sorted alphabetically or ascending may occasionally need to be sorted. To sort data, Excel enables you to make your own unique lists.

    Suppose you want to sort the dataset based on Department in the following order – IT, Sales, Marketing

    • Select the dataset > Click on the Sort option in the Data tab
    • Choose the Department column to sort
    • Under Sort On, select Cell Values
    • Choose the Custom List, under Order
    • In the Custom Lists dialog box, add the List entries separated by commas – IT, Sales, Marketing
    • Click on Add > Select OK.

    Custom Sorting Excel

    Custom Sorting

    The result of the same is displayed below.

    Sorted Data Excel

    Sorted Data

    Data sorting using a single column was demonstrated. You were aware of how sorting functions when numerous columns are involved. Additionally, you learned about MS Excel’s capability for custom sorting.

    FAQs on Sorting in Excel

    1. What are the types of sorting in Excel?

    There are 3 ways in which you can sort data in Excel.

    • Sort A to Z (Sorts in Ascending Order)
    • Sort Z to A (Sorts in Descending Order)
    • Custom Sort (Sorts by applying different sort criteria)

    sorting in excel

    Table of Contents

    • Sorting in Excel
    • Examples of Sorting in Excel

    Sorting in Excel

    Sorting in excel is nothing but arranging data stored in excel according to your requirement. It can be done by depending on the value type stored in cells. Some common examples include sorting alphabetically (A to Z or Z to A), by value (largest to smallest or smallest to largest), by day of the week (Mon, Tue, Wed..), or by month names (Jan, Feb..) etc. Filter Method sorting in Excel can be done depending on the type of data (number or text); there are many ways to sort data using the filter method.

    With basic sorting, there are few problems like multiple columns in sort not available; customized list sorting cannot be done with basic sorting. To overcome this, the Advanced sorting option is available in Excel; by using that, we can eliminate the above-mentioned limitations; also, it has wonderful features of sorting depending upon cell color and cell icon. (Explained later in this guide), Multi-level sorting can be done by advanced sorting. You can also build your own criteria in Excel for sorting. To sort any particular dataset, select the entire dataset, go to the Data tab click on the SORT Option. The hotkey is (Alt key + A+ SS).

    Sorting in excel hot keys

    Examples of Sorting in Excel

    Let’s understand the following examples of sorting in excel.

    You can download this Sorting Excel Template here – Sorting Excel Template

    Example#1

    • Suppose you have data as shown below:

    Sorting in excel

    • Now the data in the above image can be sorted based on employee name, i.e. alphabetically (A to Z or Z to A) or on the basis of Total sales. (numerically- lowest to highest or highest to lowest).

    Sorting in excel A to Z

    • While in the above case, sorting is done on the basis of one column, but what if you have data something like in the below image, So to do sorting on the basis of 2 or more columns, you need to take some additional steps.

     some additional steps

    • In the above illustration, you want to sort data at multiple levels, E.g. You want to first sort data by reporting manager, then by employee name and then by order total (highest to lowest). Why is it required? Suppose you have to find out which employee of every manager has done the maximum order sales.? You can find out answers to queries like this by using multi-level sorting. This can be only be done by advanced sorting. So to sort data at multiple levels. Simply select the entire dataset and Press (Alt key +A+ SS).

    Sorting in excel

    • This will open a dialogue box like this:

    dialogue box

    • In the above dialogue box, you have to fill your requirements for sorting in cells and add levels one by one.

    add levels one by one

    • Now, as shown in the above image, I have applied sorting criteria, it will give results something like this:

    sorting criteria

    Options available in sorting dialogue box:

    1. Add Level: to add different levels to mention sorting criteria depending on the dataset.
    2. Delete Level: to delete any particular level
    3. Level: to copy any particular level. (Generally used when sorting is required on the same column but with different values.)
    4. Arrow Buttons: to move any level above or below.
    5. Options: Here, you can select the level orientation of sorting and if values are case sensitive or not.
    6. My Data Headers: Check if your dataset has headers.
    7. Columns: This will contain all headers of your data.
    8. Sort on: Here, you can mention you want to sort data on the basis of cell values, cell color, font color or conditional formatting.
    9. Order: Data should be sorted A-Z, Z-A, smallest to largest, largest to a smallest or customized list.

    You can look at some of them in the below Screenshots.

    Sorting in excel

    Sorting Options

    Sorting Options

    The column having all headers

    Column having all headers

    Sorting Options

    Sorting in excel 11

    Example#2

    • Now taking the same data as given in the first example, you are going through all the orders, and you have doubt that few orders are wrongly punched, or you have some issues with it. You have highlighted all the orders having issues with yellow color. Suppose,
    1. Orders wrongly punched marked with red.
    2. Orders with a total value of less than 1000 are marked with yellow.

    marked with yellow

    • So we will select the data from the sheet.

    data from the sheet

    • Now you want to sort data so that you can find out which employee of each Reporting Manager has punched wrong orders and orders with a value less than 1000; you will give sorting criteria.

     Reporting Manager

    • And the sorted data will be like this:

    And the sorted data will be like this:

    There is another way to sort data at multi-levels(Explained later). However, the above-mentioned method has more steps as compared to the multi-level sorting method; it is still recommended to use this one because it is less confusing. Multi-level sorting can be done in two ways: –

    1. By using the Dialogue box (Discussed in the above 2 Examples)
    2. Using Sort Icons

    Example#3

    • We will use the same data of previous examples, now using the sorting icon. Both the methods mentioned above works in the same way; the only difference is that here in the sorting icon method, the last level is sorted first and then goes to the first level Viz. sorting is done from bottom to top. Confusing? Isn’t it?

    Confusing

    • So now, select the column you want to sort last. (E.g. Order Total in our case).

    Sorting in excel example 3.0.1

    • Now go to Data Table and Sort and click on Z-A to. (This will sort the order total from largest to smallest). Hot Key (Alt Key +A+ SD).

    Sorting in excel example 3.1

    • Excel is smart enough to recognize that you have data stored in a column behind or next to it. After clicking the sorting icon, a pop-up window will appear; it will ask you whether to expand the selection? Or continue with the current selection? Make sure to expand the selection.

    Sorting in excel example 3.2

    • And the result is shown in the below image.

    Sorting in excel example 3 result 1

    • Now, select the Employee name column and repeat the above steps.

    sorting in excel example 3 from A-Z-1

    • Here click on the A-Z option in Sort & Filter. Hot Key (Alt Key +A+ SA).

    Sorting in excel example 3.3

    • And the result is shown below.

    sorting in excel example 3 from A-Z-result 1

    • And same steps for Reporting Manager select the Reporting Manager Column.

    sorting in excel example 3 from A-Z-2

    • And then click on the A-Z option in Sort. Hot Key (Alt Key +A+ SA).

    Sorting in excel example 3.3

    • And the result is shown below.

    sorting in excel example 3 from A-Z-result 2

    While both the methods work fine, it is still recommended to use the dialogue box method because it is less prone to errors, as we can clearly see which level is getting sorted in which order.

    Things to Remember about Sorting in Excel

    • Sorting in Excel is arranging data according to our requirements.
    • It can be done alphabetically or numerically.
    • Basic Sorting works when sorting is to do on only one column.
    • Advanced Sorting is used in multi-level sorting, viz sorting required in 2 or more than 2 columns.
    • Two methods can do advanced Sorting:
    1. Sorting Dialogue Method
    2. Sorting Icon Method

    Recommended Articles

    This has been a guide to Sorting in Excel. Here we discuss Sorting in Excel and how to use the Sorting in Excel along with practical examples and downloadable excel template. You can also go through our other suggested articles –

    1. Excel Sort By Number
    2. Sort Column in Excel
    3. VBA Sort
    4. Excel Sort by color


    Download Article


    Download Article

    Excel is great for tables of data, but how can you manipulate and organize it so that it meets your needs? The Sort tool allows you to quickly sort columns by a variety of formats, or create your own custom sort for multiple columns and types of data. Use the Sort function to logically organize your data and make it easier to understand and use.

    1. Image titled Sort a List in Microsoft Excel Step 1

      1

      Select your data. You can either click and drag to select the column that you want to sort, or you can click one of the cells in the column to make it active and let Excel select the data automatically.

      • All of your data in the column will need to be formatted in the same way in order to sort (i.e. text, numbers, dates).
    2. Image titled Sort a List in Microsoft Excel Step 2

      2

      Find the Sort buttons. These can be found in the Data tab in the «Sort & Filter» section. To do quick sorts, you will be using the «AZ↓» and «AZ↑» buttons.

      Advertisement

    3. Image titled Sort a List in Microsoft Excel Step 3

      3

      Sort your column by clicking the appropriate button. If you are sorting numbers, you can sort from lowest to highest («AZ↓») or highest to lowest («AZ↑»). If you are sorting text, you can sort in ascending alphanumeric order («AZ↓») or descending alphanumeric order («AZ↑»). If you are sorting dates or times, you can sort from earlier to later («AZ↓») or later to earlier («AZ↑»).

      • If there is another column of data next to the one you are sorting, you will be asked if you want to include that data in the sort. The sort will still be the column you originally selected, but associated columns of data will be sorted along with it.
    4. Image titled Sort a List in Microsoft Excel Step 4

      4

      Troubleshoot a column that won’t sort. If you are running into errors when you try to sort, the most likely culprit is formatting problems with the data.

      • If you are sorting numbers, make sure that all of the cells are formatted as numbers and not text. Numbers can be accidentally imported as text from certain accounting programs.
      • If you are sorting text, errors can arise from leading spaces or bad formatting.
      • If you are sorting dates or times, troubles usually stem from the formatting of your data. In order for Excel to sort successfully by date, you need to ensure that all of the data is stored as a date.
    5. Advertisement

    1. Image titled Sort a List in Microsoft Excel Step 5

      1

      Select your data. Let’s say you have a spreadsheet with a list of customer names as well as the city that they are located in. To make your life easier, you want to sort first alphabetically by city, and then sort each customer alphabetically within each city. Creating a custom sort can do just that.

    2. Image titled Sort a List in Microsoft Excel Step 6

      2

      Click the Sort button. This can be found in the «Sort & Filter» section of the Data tab. The Sort window will open, allowing you to create a custom sort with multiple criteria.

      • If your columns have headers in the first cell, such as «City» and «Name», make sure to check the «My data has headers» box in the upper-left corner of the sort window.
    3. Image titled Sort a List in Microsoft Excel Step 7

      3

      Create your first rule. Click the «Sort by» menu to choose the column that you want. In this example, you would first be sorting by city, so select the appropriate column from the menu.

      • Keep «Sort on» set to «Values».
      • Set the order to either «A to Z» or «Z to A» depending on how you want to sort.
    4. Image titled Sort a List in Microsoft Excel Step 8

      4

      Create your second rule. Click the «Add Level» button. This will add a rule underneath the first one. Select the second column (The Name column in our example) and then select the sort order (for ease of reading, choose the same order as your first rule).

    5. Image titled Sort a List in Microsoft Excel Step 9

      5

      Click OK. Your list will be sorted according to your rules. You should see the cities listed alphabetically, and then the customer names sorted alphabetically within each city.

      • This example is a simple one and only includes two columns. You can, however, make your sort as complex as you would like, and include many columns.[1]
    6. Advertisement

    1. Image titled Sort a List in Microsoft Excel Step 10

      1

      Select your data. You can either click and drag to select the column that you want to sort, or you can click one of the cells in the column to make it active and let Excel select the data automatically.

    2. Image titled Sort a List in Microsoft Excel Step 11

      2

      Click the Sort button. The Sort button can be found in the Data tab in the «Sort & Filter» section. This will open the Sort window. If you have another column of data next to the one you are sorting, you will be asked if you want to include that data in the sort.

    3. Image titled Sort a List in Microsoft Excel Step 12

      3

      Select «Cell Color» or «Font Color» in the «Sort On» menu. This will allow you to choose the first color you want to sort by.

    4. Image titled Sort a List in Microsoft Excel Step 13

      4

      Select which color you want to sort first. In the «Order» column, you can use the drop down menu to choose which color you want to put first or last in the sort. You can only choose colors that are present in the column.

      • There is no default order for color sorting. You will need to define the order yourself.
    5. Image titled Sort a List in Microsoft Excel Step 14

      5

      Add another color. You will need to add another rule for each color in the column you are sorting. Click the «Add Level» to add another rule to the sort. Choose the next color that you want to sort by, and then the order that you want to sort.

      • Make sure that each order is the same for each rule. For example, if you are sorting from top to bottom, make sure the «Order» section for each rule says «On Top».
    6. Image titled Sort a List in Microsoft Excel Step 15

      6

      Click OK. Each rule will be applied one by one, and the column will be sorted by the colors you defined.

    7. Advertisement

    Add New Question

    • Question

      How can the sort function on Microsoft Word help me?

      Community Answer

      Let’s say you are a teacher and you have a database of students with their assignment grades. By sorting on assignment type and grade received, you can find the students who need more help. In other words, sorting allows one to focus attention where it is most needed.

    • Question

      I tried to sort by color, but the only thing in the Sort On dropdown is «no cell color». Why do I not have any colors to choose from?

      Community Answer

      You have to format your data’s cells with colors first in order to sort by color.

    • Question

      How do I store results of a sort into a new table while retaining the original table?

      Community Answer

      Copy the table (and show results of your sort) into a new page.

    Ask a Question

    200 characters left

    Include your email address to get a message when this question is answered.

    Submit

    Advertisement

    wikiHow Video: How to Sort a List in Microsoft Excel

    • Try sorting data in different ways; these new perspectives can illuminate different aspects of the information.

    • If your spreadsheet has totals, averages or other summary information below the information you need to sort, be careful not to sort those as well.

    Thanks for submitting a tip for review!

    Advertisement

    • Be extremely careful to select all of the columns you need when sorting.

    Advertisement

    References

    About This Article

    Article SummaryX

    To sort your data alphabetically or numerically, start by highlighting the cells you want to sort. Then, click the «Data» tab at the top of Excel. In the «Sort & Filter» panel in the toolbar, click the AZ with a down-arrow to sort in alphabetical or numerical order, starting with the smallest values first, or AZ with an up-arrow to reverse that sorting method, or starting with the largest values first. You can also sort by font or cell color. With your data selected, click the Data tab, and then click «Sort» on the «Sort & Filter» panel. If your data has headers, check the box near the top-right corner. Select a column, and then choose how to sort it, such as by cell or font Color. Click the «Order» menu to choose a color to sort first, and select «On Top» from the drop-down menu. To add the next color in the sequence, click «Add Level,» and select the same column and sorting method. Choose the color that should appear next and select «On Top» again. Keep adding rules for the column until you’ve placed all colors in order, and then click «OK» to sort. Just like adding rules to sort by color, you can add rules to sort columns by multiple criteria, such as both alphabetically and by cell color. In the Sort window, select a column, and then enter the sorting method and criteria. Click «Add Level» to add another rule, pick the same column, and then choose a different sorting method. Click «OK» when you’re finished to save and sort.

    Did this summary help you?

    Thanks to all authors for creating a page that has been read 231,999 times.

    Is this article up to date?

    Lesson 19: Sorting Data

    /en/excel2016/freezing-panes-and-view-options/content/

    Introduction

    As you add more content to a worksheet, organizing this information becomes especially important. You can quickly reorganize a worksheet by sorting your data. For example, you could organize a list of contact information by last name. Content can be sorted alphabetically, numerically, and in many other ways.

    Optional: Download our practice workbook.

    Watch the video below to learn more about sorting data in Excel.

    Types of sorting

    When sorting data, it’s important to first decide if you want the sort to apply to the entire worksheet or just a cell range.

    • Sort sheet organizes all of the data in your worksheet by one column. Related information across each row is kept together when the sort is applied. In the example below, the Contact Name column (column A) has been sorted to display the names in alphabetical order.

      A sorted worksheet

    • Sort range sorts the data in a range of cells, which can be helpful when working with a sheet that contains several tables. Sorting a range will not affect other content on the worksheet.

      Sorting a range

    To sort a sheet:

    In our example, we’ll sort a T-shirt order form alphabetically by Last Name (column C).

    1. Select a cell in the column you want to sort by. In our example, we’ll select cell C2.

    2. Select the Data tab on the Ribbon, then click the A-Z command to sort A to Z, or the Z-A command to sort Z to A. In our example, we’ll sort A to Z.

    3. The worksheet will be sorted by the selected column. In our example, the worksheet is now sorted by last name.

    To sort a range:

    In our example, we’ll select a separate table in our T-shirt order form to sort the number of shirts that were ordered in each grade.

    1. Select the cell range you want to sort. In our example, we’ll select cell range G2:H6.

      Selecting cells

    2. Select the Data tab on the Ribbon, then click the Sort command.

      The Sort button on the Data tab

    3. The Sort dialog box will appear. Choose the column you want to sort by. In our example, we want to sort the data by the number of T-shirt orders, so we’ll select Orders.

      The Sort dialog box

    4. Decide the sorting order (either ascending or descending). In our example, we’ll use Largest to Smallest.
    5. Once you’re satisfied with your selection, click OK.

      The Sort dialog box

    6. The cell range will be sorted by the selected column. In our example, the Orders column will be sorted from highest to lowest. Notice that the other content in the worksheet was not affected by the sort.

      The range has been sorted

    If your data isn’t sorting properly, double-check your cell values to make sure they are entered into the worksheet correctly. Even a small typo could cause problems when sorting a large worksheet. In the example below, we forgot to include a hyphen in cell A18, causing our sort to be slightly inaccurate.

    A typo can ruin a sort

    Custom sorting

    Sometimes you may find that the default sorting options can’t sort data in the order you need. Fortunately, Excel allows you to create a custom list to define your own sorting order.

    To create a custom sort:

    In our example below, we want to sort the worksheet by T-Shirt Size (column D). A regular sort would organize the sizes alphabetically, which would be incorrect. Instead, we’ll create a custom list to sort from smallest to largest.

    1. Select a cell in the column you want to sort by. In our example, we’ll select cell D2.

      Selecting cells

    2. Select the Data tab, then click the Sort command.

      The Sort button on the Data tab

    3. The Sort dialog box will appear. Select the column you want to sort by, then choose Custom List… from the Order field. In our example, we will choose to sort by T-Shirt Size.

      The Sort dialog box

    4. The Custom Lists dialog box will appear. Select NEW LIST from the Custom Lists: box.
    5. Type the items in the desired custom order in the List entries: box. In our example, we want to sort our data by T-shirt size from smallest to largest, so we’ll type Small, Medium, Large, and X-Large, pressing Enter on the keyboard after each item.

      The Custom Lists dialog box

    6. Click Add to save the new sort order. The new list will be added to the Custom lists: box. Make sure the new list is selected, then click OK.

      Clicking OK

    7. The Custom Lists dialog box will close. Click OK in the Sort dialog box to perform the custom sort.

      Clicking OK

    8. The worksheet will be sorted by the custom order. In our example, the worksheet is now organized by T-shirt size from smallest to largest.

      The sheet has now been sorted with our custom criteria.

    Sorting levels

    If you need more control over how your data is sorted, you can add multiple levels to any sort. This allows you to sort your data by more than one column.

    To add a level:

    In our example below, we’ll sort the worksheet by T-Shirt Size (Column D), and then by Homeroom Number (column A).

    1. Select a cell in the column you want to sort by. In our example, we’ll select cell A2.

      Select cells

    2. Click the Data tab, then select the Sort command.

      The Sort button on the Data tab

    3. The Sort dialog box will appear. Select the first column you want to sort by. In this example, we will sort by T-Shirt Size (column D) with the custom list we previously created for the Order field.
    4. Click Add Level to add another column to sort by.

      The Sort dialog box

    5. Select the next column you want to sort by, then click OK. In our example, we’ll sort by Homeroom # (column A).

      The Sort dialog box

    6. The worksheet will be sorted according to the selected order. In our example, the orders are sorted by T-shirt size. Within each group of T-shirt sizes, students are sorted by homeroom number.

      The multi-level sort is applied to the worksheet

    If you need to change the order of a multilevel sort, it’s easy to control which column is sorted first. Simply select the desired column, then click the Move Up or Move Down arrow to adjust its priority.

    Move levels up or down

    Challenge!

    1. Open our practice workbook.
    2. Click the Challenge tab in the bottom-left of the workbook.
    3. For the main table, create a custom sort that sorts by Grade from Smallest to Largest and then by Camper Name from A to Z.
    4. Create a sort for the Additional Information section. Sort by Counselor (Column H) from A to Z.
    5. When you’re finished, your workbook should look like this:

      Sorting Challenge

    /en/excel2016/filtering-data/content/

    Понравилась статья? Поделить с друзьями:
  • How to do revisions in word
  • How to do regressions in excel
  • How to do regression in excel
  • How to do ranking in excel
  • How to do probabilities in excel