Track
Whether you're managing financial records, tracking inventory, or analyzing survey responses, sorting allows you to arrange your data in a logical order for better readability and decision-making.
In this guide, I will walk you through various sorting techniques, from simple sorting to more advanced options like custom sorting. If you find yourself getting stuck with other Excel questions, I recommend taking our Introduction to Excel course and the Data Preparation in Excel course for a strong foundation.
How to Sort By a Condition in Excel
Excel provides sorting options that allow you to organize data based on different conditions, like sorting by date or by color.
How to sort by date in Excel
If you want to sort a column by date:
- Select the data containing the dates.
- Go to the Data tab and click Sort.
- In the Sort window, choose the column with dates under Column.
- Under Sort On, select Cell Values.
- Choose Oldest to Newest or Newest to Oldest under Order.
- Click OK to apply the sorting.

How to sort by date in Excel. Image by Author.
How to sort by color in Excel
To sort data by color:
- Select the data range that includes colored cells.
- Open the Sort tool from the Data tab.
- In the Sort window, select the column that contains the color formatting.
- Under Sort On, choose Cell Color.
- Select the color you want to sort by and choose On Top or On Bottom under Order.
- Click OK to apply the sorting.

How to sort by color in excel. Image by Author.
How to sort by column in Excel
Sorting by a column is straightforward and can be done for multiple columns.
- Highlight the dataset you want to sort.
- Click on the Data tab and select Sort.
- In the Sort window, choose the column you want to sort by.
- Under Sort On, choose Cell Values.
- Choose Ascending (A-Z) or Descending (Z-A) for text or Smallest to Largest / Largest to Smallest for numbers.
- Click OK to sort the selected column.

How to sort by column in Excel. Image by Author.
How to sort by alphabetical order in Excel
Alphabetical sorting is useful for text data. To sort the data:
- Click anywhere inside the column you want to sort.
- Navigate to the Data tab.
- Click Sort A to Z (for ascending order) or Sort Z to A (for descending order).
- If your data has headers, ensure My data has headers is checked in the Sort window.
- Click OK to apply the alphabetical sorting.

How to sort by alphabetical order in Excel. Image by Author.
Check out our tutorial How to Alphabetize in Excel, to learn more about the different techniques of sorting data in alphabetical order.
How to sort by number in Excel
Sorting by numbers helps organize numerical data. To sort data by number:
- Select the column that contains numerical values.
- Go to the Data tab and click Sort.
- In the Sort window, choose the column with numbers.
- Under Sort On, select Cell Values.
- Choose Smallest to Largest or Largest to Smallest under Order.
- Click OK to apply the sorting.

How to sort by number in Excel. Image by Author.
How to Sort Columns in Excel
Sorting columns in Excel helps organize data efficiently, whether you need to arrange a single column alphabetically or sort multiple columns for better analysis. The following are different methods of sorting columns while preserving data integrity.
How to sort a single column in Excel
Sorting a single column in Excel is quick and easy using the Sort & Filter group in the Data tab. Follow these steps:
- Select the dataset you want to sort.
- Navigate to the Data tab.
- In the Sort & Filter group, choose A to Z to sort in ascending order or Z to A to sort in descending order.
- If only one column is selected, Excel will prompt you with a warning; "Do you want to expand the selection?"

Expand selection in sort in Excel. Image by Author.
- Select Expand the selection to keep the data in each row together. Select Continue with the current selection only if sorting the column independently.
- Click OK, and Excel will sort the column accordingly.

How to sort a single column in Excel. Image by Author.
Always ensure that the full dataset is selected or that Expand Selection is enabled. Otherwise, sorting a single column without expanding may disrupt row relationships and misalign data.
How to sort by multiple columns in Excel
If you need to sort based on more than one criterion, like sorting employees by Department first and then by Last Name, follow these steps:
- Select your entire dataset, including the headers.
- Go to the Data tab and click Sort to open the Sort dialog box.
- In the Sort window, choose the primary column to sort by, for example, "Department." Under Order, select A to Z or Z to A.
- Click Add Level to sort by a second column like "Last Name".
- Choose the secondary column and sorting order.
- Repeat the previous step if you need to add more sorting levels.
- Click OK to apply the multi-level sorting.

How to sort by multiple columns in Excel. Image by Author.
By using the multi-column sorting approach, Excel organizes the data hierarchically.
Custom Sorting Techniques in Excel
Excel provides custom sorting options that allow you to organize data based on cell color, font color, or icons instead of just values. These techniques are particularly useful when colors or icons highlight important data, such as urgent tasks, top performers, or flagged errors.
Sorting by cell color
Sorting by cell color is useful when colors highlight different categories, such as high-priority tasks or flagged data. Follow these steps to sort by color:
- Select your dataset.
- Click on the Data tab and select Sort.
- In the Sort window, choose the column containing the colored cells. Under Sort On, select Cell Color.
- Under Order, pick a color to appear at the top or bottom.
- Click OK, and Excel will arrange the rows based on cell color priority.

Sorting by cell color in Excel. Image by Author.
Sorting by font color
Sorting by font color helps when the text color indicates priority, such as red for urgent or green for completed tasks. For example, sorting red-colored negative balances to the top for review. To sort by font color:
- Select your data range.
- Go to the Data tab and click Sort.
- In the Sort window, choose the column where font colors differ. Under Sort On, select Font Color.
- Under Order, select which font color should appear first.
- Click OK, and Excel will sort based on font color.

Sorting by font color in Excel. Image by Author.
Sorting by icon
Sorting by cell icon works best when data is labeled using Conditional Formatting icons. For example, you can use ✔ for completed, ⚠ for warnings, and ❌ for errors. To sort data using this method:
- Select the data containing icons.
- Click the Data tab and choose Sort.
- In the Sort window, choose the column with icons. Under Sort On, select Cell Icon.
- Under Order, choose which icon should appear first.
- Click OK to apply the sorting.

Sorting by icon in Excel. Image by Author.
Other Interesting Excel Sorting Problems
Beyond basic sorting, Excel provides advanced techniques to solve unique challenges.
How to sort birthdays by month in Excel
Sorting a list of birthdays by month while ignoring the year requires a custom approach because Excel sorts dates chronologically by default. Follow these steps to sort birthdays by month only:
-
Assume your dataset has a column named "Birthday" with full birthdates like
12/05/1990,08/21/1985). -
In an empty column, extract the month using the formula below, which converts the date into a two-digit month format (
01-12).
=TEXT(A2, "MM")
Sort by this new column from smallest to largest.

How to sort by month in Excel. Image by Author.
How to sort in Excel and keep rows together
When sorting a single column, Excel may ask if you want to Expand the selection. If you don't expand, only the selected column will be sorted, misaligning data. Follow the steps below to keep rows together while sorting:
- Select the entire dataset, not just one column.
- Go to the Data tab and click Sort.
- Choose the column by which you want to sort.
- Make sure Expand the selection is selected.

How to expand selection in Excel. Image by Author.
- Click OK, and Excel will keep rows intact while sorting.

How to sort in Excel and keep rows together. Image by Author.
How to sort multiple columns in Excel and keep rows together
Sorting multiple columns allows you to prioritize data hierarchy, ensuring meaningful organization. Use the steps below to sort multiple columns:
- Select the entire dataset, including column headers.
- Click Sort in the Data tab.
- Choose the first column to sort by, such as "Department."
- Click Add Level to sort by a second column such as "Name."
- Repeat Step 4 for additional levels.
- Click OK, and Excel will sort based on your selected hierarchy.

How to sort multiple columns in Excel and keep rows together. Image by Author.
Sorting horizontally (left to right)
Excel’s default sorting is vertical (top to bottom), but sometimes you need to sort data horizontally (left to right), such as when dealing with transposed tables or timeline data. Follow the steps below to sort your data horizontally.
- Select the row you want to sort.
- Click the Data tab, then Sort.
- Click Options in the Sort window.
- Under Orientation, choose Sort left to right and click OK.

How to sort left to right in Excel. Image by Author.
- Select the row number to sort by.
- Choose the order A-Z or Z-A.
- Click OK to apply the sorting.

How to sort horizontally in Excel. Image by Author.
How to Apply a Custom Sort in Excel
Custom sorting in Excel allows you to define your order for sorting data, which is particularly useful when the default alphabetical or numerical order doesn't meet your needs. The following are examples of when to use custom sorting:
- Sorting departments: You can sort departments in the order IT > Sales > Marketing instead of alphabetical order.
- Prioritizing status levels: High > Medium > Low.
- Arranging days of the week: Monday > Tuesday > Wednesday.
- Sorting months: January > February > March.
Below are the steps on how to apply a custom sort:
Select Your dataset (including headers).
- Go to the Data tab and click Sort.
- In the Sort window, choose the column to sort, such as "Department."
- Under Order, click the dropdown and select Custom List.

How to apply a custom sort in Excel. Image by Author.
- In the Custom Lists window, either select an existing list, such as Days of the Week or Months, or create a new list by typing values manually, such as IT, Sales, or Marketing.
- Click OK and then OK again to apply the sort.

How to create a custom sort list in Excel. Image by Author.
Excel’s SORT() function
Although we have gone through all the most common use cases, I feel this article would be missing something if I didn't talk about Excel's SORT() function specifically. Excel’s SORT() function provides a dynamic, formula-based sorting method. It updates automatically when data changes. Below is the syntax of the SORT() function:
=SORT(array, [sort_index], [sort_order], [by_col])
Where:
-
array→ The range to sort. -
sort_index→ Column (or row) to sort by. -
sort_order→1for ascending,-1for descending. -
by_col→FALSE(default) for vertical sort,TRUEfor horizontal sort.
For example, to sort a table by "Sales ($)" in descending order, we apply the function as:
=SORT(A2:D11, 4, -1)
This function keeps the entire row together while sorting by Sales ($).

How to sort data using the SORT() function in Excel. Image by Author.
Check out our Advanced Excel Functions course to learn more about the interesting and useful excel functions, including advanced referencing and database functions.
Conclusion
Whether using basic sorting, multi-column sorting, or advanced custom orders, knowing the right tool for the job ensures efficiency and accuracy. Sorting is often the first step in broader data workflows, leading to better filtering, pivot tables, and charts for deeper analysis.
If you want to become a master in Excel, streamline your data management and make more informed decisions with ease, I recommend taking our Data Analysis in Excel to learn about insights in B2B data and Data Visualization in Excel to master data analysis and presentation. DataCamp has lots of great Excel courses and tracks, so you can browse and find the perfect fit.
Learn Excel Fundamentals
FAQs
What is sorting in Excel?
Sorting in Excel organizes data in a specific order, such as alphabetically, numerically, or by date.
How do I sort a column without affecting other data?
Always select the entire dataset before sorting to keep rows intact. If sorting one column, choose Expand Selection when prompted.
Can I sort by more than one column at a time?
Yes! Use the Sort dialog box to add multiple levels, sorting hierarchically by different criteria.
Can I sort rows instead of columns?
Yes! In the Sort Options menu, select Sort left to right to sort data horizontally.
Does Excel have a formula to sort data automatically?
Yes! The SORT() function dynamically arranges data based on set criteria and updates when data changes.

