Sort a list of data

Some of the content in this topic may not be applicable to some languages.

In Excel, you can sort numbers, text, weekdays, months, or items from custom lists that you create. You can also sort by font color, cell color, or icon sets.

When you sort a column, you rearrange the rows of the column. When you sort multiple columns, or a table, you rearrange all the rows based on the contents of a particular column.

Important: If the columns that you want to sort contain both numbers that are stored as numbers and numbers that are stored as text, the numbers will not sort correctly. Numbers that are stored as text are aligned left instead of right. To format selected numbers consistently, on the Home tab, under Number, in the Number Format box, select Text or Number.

Do any of the following:

Sort a column

  1. Click a cell in one of the columns that you want to sort.

    Data in adjacent columns will be sorted based on the column that you sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort.

    Data tab, Sort & Filter group

  3. Do one of the following:

To sort

Click

The lowest values to the top of the column

Ascending

The highest values to the top of the column

Descending

  1. Note: If the results aren't what you expected, check that all numbers are stored as numbers. For example, negative numbers imported from some accounting systems are stored as text.

Sort a list by two or three columns

You can sort by several columns by adding levels of sorting criteria. For example, you could sort a sales report by region, then by date, and then by salesperson. Each sort level is represented by a single row in the Sort dialog box.

  1. Click a cell in one of the columns that you want to sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Custom Sort.

    Data tab, Sort & Filter group

  3. Click Add Level  Add button, Sort box .

    If the table has a header row, select the My list has headers check box. But if the table does not have a header row, clear the My list has headers check box.

  4. Under Column, click the blank space next to Then by, and then on the shortcut menu, click the column that you want to sort by.

  5. Under Sort On in the same row, click Values, and then on the shortcut menu, click the criteria that you want.

  6. Under Order in the same row, click A to Z, and then on the shortcut menu, click the criteria that you want.

    If you selected Font Color, Cell Color, or Cell Icon in step 5, then under Color/Icon, click the row, and then on the shortcut menu, click the criteria that you want.

  7. For each column that you want to sort by, repeat steps 3 through 6.

Sort a list by rows

  1. Click a cell in the row that you want to sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Custom Sort.

    Data tab, Sort & Filter group

  3. Click Options.

  4. Under Orientation, click Sort left to right, and then click OK.

  5. Click Add Level  Add button, Sort box .

  6. Under Row, click the blank space next to Then by, and then on the shortcut menu, click the row that you want to sort next.

  7. Under Sort On in the same row, click Values, and then on the shortcut menu, click the criteria that you want.

  8. Under Order in the same row, click A to Z, and then on the shortcut menu, click the criteria that you want.

  9. For each row that you want to sort by, repeat steps 5 through 8.

Create a custom list to sort with

Excel includes custom lists that you can sort by: days of the week and months of the year. In addition, you can create your own custom lists, for example, grade levels in a school, such as Freshman, Sophomore, Junior, and Senior.

  1. On the Excel menu, click Preferences, and then under Formulas and Lists, click Custom Lists   Custom List Preferences button .

  2. Click Add.

  3. Type your list entries in the order that you want them sorted. When you are finished, click OK.

Sort by a custom list

Excel includes custom lists that you can sort by: days of the week and months of the year. In addition, the previous procedure explains how you can create your own custom lists, for example, grade levels in a school, such as Freshman, Sophomore, Junior, and Senior.

  1. Click a cell in one of the columns that you want to sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Custom Sort.

    Data tab, Sort & Filter group

  3. Click Add Level  Add button, Sort box .

    If the table has a header row, select the My list has headers check box. But if the table does not have a header row, clear the My list has headers check box.

  4. Under Order, click the current sort order, such as A to Z, and then click Custom List.

  5. Select the list that you want to sort by, and then click OK.

    Note: The custom sort order applies only to the column specified under Column. To sort multiple columns by weekday, month, or another custom list, use the previous "Sort a list by two or three columns" procedure to sort each column separately.

Sort dates or times

  1. Select a column of dates or times in a range of cells or in a table.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Ascending or Descending.

    Data tab, Sort & Filter group

    Note: If the results are not what you expected, the column might contain dates or times that are stored as text or numbers, instead of as dates or times. To store the numbers in date or time format, select the column, and on the Home tab, under Number, point to Number Format, and then click Date or Time.

Sort by cell color, font color, or icon

If there are cells formatted by cell color or font color in the column that you are sorting, you can sort by these colors. You can also sort by an icon set that was created by using a conditional format. Because there is no default sort order for cell color, font color, or icons, you must define your own order for each sort operation.

  1. Click a cell in one of the columns that you want to sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Custom Sort.

    Data tab, Sort & Filter group

  3. Click Add Level  Add button, Sort box .

    If the table has a header row, select the My list has headers check box. But if the table does not have a header row, clear the My list has headers check box.

  4. Under Column, click the blank space next to Then by, and then on the shortcut menu, click the column that you want to sort by.

  5. Under Sort On in the same row, click Values, and then on the shortcut menu, click Cell Color, Font Color, or Icon Color.

  6. For each column that you want to sort by, repeat steps 3 through 5.

Sort one column in a range of cells without affecting the other columns

Important: Be careful when you use this feature. Sorting by one column in a range can produce results that you don't want, such as moving cells in that column away from other cells in the same row.

  1. Select a column in a range of cells that contains two or more columns.

    Note: This procedure cannot be performed in a table.

  2. Select the column data that you want to sort.

  3. On the Data tab, under Sort & Filter, click Sort.

    Data tab, Sort & Filter group

  4. In the Sort Warning that appears, select Continue with the current selection, and then click Sort.

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

Sort Chinese text by character pronunciation or character stroke numbers in Excel

You can sort Chinese text by Chinese character pronunciation or Chinese character stroke numbers.

Important: To complete this procedure, you must first turn on Chinese language features. For more information, see Turn on Chinese language features.

  1. Click a cell in one of the columns that you want to sort.

  2. On the Data tab, under Sort & Filter, click the arrow next to Sort, and then click Custom Sort.

    Data tab, Sort & Filter group

  3. To add another sorting criteria, click Add Level  Add button, Sort box .

    If the table has a header row, select the My list has headers check box. But if the table does not have a header row, clear the My list has headers check box.

  4. To change the sort order, under Order, click the current sort order, such as A to Z, and then click Custom List.

  5. Click Options, and then do one or more of the following:

To

Do this

Sort top to bottom

Under Orientation, click Sort top to bottom.

Sort left to right

Under Orientation, click Sort left to right.

Sort by stroke ordering

Under Method, click Stroke Ordering.

Sort by syllabary ordering

Under Method, click Syllabary Ordering.

  1. Click OK.

    Note: The custom sort order applies only to the column specified under Column. To sort multiple columns by weekday, month, or another custom list, use the previous "Sort a list by two or three columns" procedure to sort each column separately.

See also

About sorting

About filtering

Filter a list of data

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×