How to Sort Data in Excel

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: 

WindowsWeb

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.

Sort numbers
  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.

Sort dates or times
  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.

Related Videos