Excel Practice Test

โ–ถ

Sorting a column in Excel sounds simple โ€” until it isn't. You click the wrong button, the entire dataset shuffles out of order, and your carefully labeled rows end up pointing at the wrong data. Understanding how excel sorts data โ€” and when each method applies โ€” saves you from those frustrating undo loops.

Excel gives you several ways to sort a column. The quickest is a right-click on any cell in the column you want sorted, then choosing Sort A to Z or Sort Z to A. That works great for a single, isolated column. But when your data has related rows โ€” like a customer list where the name, email, and order total all belong together โ€” you need Excel to move entire rows, not just the values in one column.

That's where the Data tab โ†’ Sort dialog becomes your go-to tool. It sorts full rows based on the values in a column you choose as the sort key. You can stack up to 64 levels in a single sort operation โ€” handy when you're ranking sales data first by region, then by salesperson, then by revenue.

For keyboard lovers, Excel sort shortcut key sequences like Alt + A + S + A (ascending) and Alt + A + S + D (descending) let you sort without touching the mouse. Ctrl + Shift + L toggles filter dropdowns that include sorting options right in the column header.

Excel 365 and Excel 2021 users also have access to the dynamic SORT function โ€” a formula that returns a sorted copy of a range, updating automatically when source data changes. No button-clicking required.

Before you start sorting, it's worth understanding the difference between sorting a range and sorting an Excel Table. A plain range requires you to be careful about selecting the right cells and confirming the "expand selection" dialog. An Excel Table โ€” created with Ctrl + T โ€” handles this automatically. Every sort on a Table moves complete rows, no dialog needed, no accidental partial sorts. If you're working with a dataset you'll sort repeatedly, converting it to a Table first is the smarter move.

Dates, numbers, and text all sort correctly when Excel knows the data type. The problems start when data types are inconsistent โ€” numbers formatted as text, dates entered as plain strings, or blank cells scattered through the column. This guide shows you how to spot and fix each of those scenarios before they ruin your sort.

This guide covers every sorting scenario you'll actually run into: sorting alphabetically, sorting by number, sorting multiple columns, sorting horizontally (by row instead of column), sorting by IP address, sorting by name, and diagnosing the common reasons Excel sorting stops working as expected. Whether you're using the ribbon, keyboard shortcuts, or the dynamic SORT function, you'll find the right approach here.

Excel Sort Shortcuts โ€” Quick Reference
Alt + A + S + A โ€” Sort Aโ†’Z (ascending) | Alt + A + S + D โ€” Sort Zโ†’A (descending) | Ctrl + Shift + L โ€” Toggle filter/sort dropdowns | Right-click cell โ†’ Sort โ€” Quick context menu sort | Data tab โ†’ Sort A to Z / Sort Z to A โ€” Ribbon buttons for one-click sort

Four Essential Excel Sort Methods

๐Ÿ”ด Sort Single Column

Sort one column A-Z, Z-A, or by number โ€” fastest everyday sort.

  • Method: Click any cell in column โ†’ Data tab โ†’ Sort A to Z or Sort Z to A
  • Shortcut: Alt + A + S + A (ascending) or Alt + A + S + D (descending)
  • Gotcha: If adjacent columns contain related data, Excel asks if you want to expand the selection โ€” always choose Expand Selection to keep rows intact
๐ŸŸ  Sort Multiple Columns

Custom sort dialog lets you define primary, secondary, and tertiary sort keys โ€” up to 64 levels.

  • Method: Data tab โ†’ Sort โ†’ Add Level โ†’ choose column and order for each level
  • Shortcut: Alt + D + S opens the Sort dialog in older Excel versions
  • Gotcha: Order of sort levels matters โ€” the top level is sorted first, then lower levels sort within matching top-level groups
๐ŸŸก Sort Horizontally (By Row)

Sort columns left-to-right based on values in a single row โ€” useful for time-series headers.

  • Method: Data tab โ†’ Sort โ†’ Options โ†’ Sort left to right โ†’ choose which row to sort by
  • Shortcut: No dedicated shortcut โ€” must use the Sort dialog Options button
  • Gotcha: Excel defaults to sorting top to bottom; you must manually switch to Sort left to right in Options every time
๐ŸŸข Sort by IP Address

IP addresses sort lexicographically by default โ€” 192.168.1.10 comes before 192.168.1.9. Workarounds needed.

  • Method: Use helper columns to pad octets to 3 digits each, then sort the helper column
  • Alternative: Power Query: split IP on ".", convert each part to integer, sort by all four columns, then remove helper columns
  • Gotcha: There is no native IP-aware sort in Excel โ€” any direct sort on the IP text column will produce wrong order

How to Sort Alphabetically and Sort by Number in Excel

Alphabetical sorting in Excel is the most-used sort operation. Whether you're tidying up a contact list or organizing product names, the steps are the same โ€” and they're fast once you know the keyboard path.

Sort Alphabetically (A to Z)

Click any cell inside the column you want sorted. Don't select the whole column โ€” just one cell. Then:

  1. Go to the Data tab on the ribbon.
  2. Click Sort A to Z (the AZโ†“ icon).
  3. If Excel detects adjacent data, it'll prompt you to expand the selection. Choose Expand the Selection to keep related rows together.

Keyboard path: Alt + A + S + A โ€” press each key in sequence, not simultaneously. This triggers Sort A to Z directly from the Data tab without clicking. To sort excel sort alphabetically in reverse (Z to A), use Alt + A + S + D.

Right-click shortcut: right-click any cell in the column โ†’ hover over Sort โ†’ click Sort A to Z. Three clicks, no ribbon required.

Sort by Number (Ascending / Descending)

Numerical sorting works the same way, but Excel's button labels shift to reflect it. When your column contains numbers:

The keyboard shortcuts remain identical: Alt + A + S + A for ascending, Alt + A + S + D for descending. That consistency is worth memorizing โ€” it works regardless of whether the column holds text, numbers, or dates.

Handling Blanks and Errors When Sorting Numbers

Blank cells always move to the bottom of a sorted list, regardless of sort order. That's actually useful โ€” blanks won't disrupt the top of your sorted data. Cells containing error values like #VALUE! or #N/A sort to the bottom as well.

The trickier problem is numbers stored as text. If Excel left-aligns numbers in a column, that's a red flag โ€” they're probably text. A small green triangle in the cell corner confirms it. Sort order will be wrong: 10 sorts before 2 because text sorting compares character by character. Fix it by selecting the column, clicking the warning icon, and choosing Convert to Number.

For a general-purpose excel sort reference including date columns and mixed data types, check that linked guide for edge-case handling beyond what's covered here.

Sorting Dates in Excel

Date columns sort the same way as number columns โ€” Oldest to Newest maps to ascending, Newest to Oldest maps to descending. The shortcut Alt + A + S + A still applies. The catch is date format consistency. If some cells store dates as text ("January 5, 2024" instead of an actual date value), those cells sort separately from the real dates and end up at the top or bottom depending on their text value.

Check date alignment: real date values right-align in cells by default. Text-formatted dates left-align. If you see a mix, select the column, go to Data โ†’ Text to Columns โ†’ Finish โ€” this forces Excel to re-parse the dates as date values. Run the sort after this conversion.

Using Filters for Quick Column Sorting

If your data already has filter dropdowns visible โ€” either because you applied a filter or because you're working in a Table โ€” you can sort directly from the dropdown. Click the filter arrow in the column header, then choose Sort A to Z or Sort Smallest to Largest at the top of the dropdown list. This is often the fastest method when you're already looking at filtered data, and it sorts the full dataset (not just the visible filtered rows).

Related: if you want to how to change column width in excel after sorting so your data displays cleanly, that's a quick double-click on the column border in the header row โ€” column auto-fits to the widest value. And to keep your sorted data navigable, understanding how to indent in excel for nested or grouped items can complement your sort workflow for more readable spreadsheets.

Sorting Methods Side by Side

๐Ÿ“‹ Sort Single Column

Quick Single-Column Sort

For a single column with no related adjacent data, here's the fastest path:

  1. Click any cell in the target column.
  2. Press Alt + A + S + A (ascending) or Alt + A + S + D (descending).
  3. Done โ€” the column sorts instantly.

If adjacent columns are present, Excel shows a dialog:

  • Expand the Selection โ€” sorts entire rows based on your column. Use this for datasets where rows must stay together.
  • Continue with the Current Selection โ€” sorts only the selected column, leaving adjacent data in place. Only safe for truly isolated columns.

Using Ctrl + T to convert your range to an Excel Table first is the safest approach โ€” table sort always keeps rows intact automatically, with no dialog prompt.

Right-Click Method

Right-click any cell in the column โ†’ Sort โ†’ Sort A to Z or Sort Z to A. For numbers, the labels change to Smallest to Largest / Largest to Smallest. Same behavior, different entry point.

๐Ÿ“‹ Sort Multiple Columns

Custom Sort Dialog โ€” Step by Step

When you need to sort by more than one column โ€” say, last name then first name, or region then revenue โ€” you need the Custom Sort dialog.

  1. Click any cell inside your data range.
  2. Go to Data tab โ†’ Sort (the full Sort button, not the quick A-Z buttons).
  3. Make sure My data has headers is checked if your table has a header row.
  4. In the first row, set Sort by to your primary sort column, choose Values for Sort On, and pick A to Z or Largest to Smallest for Order.
  5. Click Add Level to add a secondary sort. Set Then by to your next column.
  6. Repeat for additional levels โ€” Excel supports up to 64 levels.
  7. Click OK.

Example: sorting a sales dataset by Region (A-Z) then by Revenue (Largest to Smallest) puts each region's top earner at the top of that group.

Sorting Multiple Columns Example

Level 1: Column C (Region) โ€” A to Z
Level 2: Column F (Revenue) โ€” Largest to Smallest
Level 3: Column B (Rep Name) โ€” A to Z

Excel processes from top level down โ€” all rows with the same Region stay grouped, and within each group, Revenue sorts descending.

๐Ÿ“‹ SORT Function (365)

Dynamic Array SORT Function โ€” Excel 365 / 2021+

The =SORT() function returns a sorted copy of a range as a dynamic array. Unlike the Sort dialog, it doesn't modify the original data โ€” it outputs a new sorted range that updates automatically when the source changes.

Syntax

=SORT(array, [sort_index], [sort_order], [by_col])

  • array โ€” the range or array to sort
  • sort_index โ€” which column (or row) to sort by; defaults to 1
  • sort_order โ€” 1 for ascending (default), -1 for descending
  • by_col โ€” FALSE to sort rows (default), TRUE to sort columns

Common Examples

Sort a single column ascending:
=SORT(A2:A50)

Sort a two-column range by the second column, descending:
=SORT(A2:B50, 2, -1)

Sort a range by its first column, ascending:
=SORT(A2:D100, 1, 1)

SORTBY for Multi-Key Sorts

For sorting by multiple columns with different orders, pair SORT with SORTBY:
=SORTBY(A2:D100, C2:C100, 1, D2:D100, -1)
This sorts rows by column C ascending, then column D descending.

Limitations

  • SORT / SORTBY require Excel 365 or Excel 2021 โ€” not available in Excel 2019 or earlier.
  • The output is a spill range โ€” make sure destination cells are empty, or you'll get a #SPILL! error.
  • Output is read-only โ€” you can't edit cells in the spill range directly.

Sort Horizontally, Sort by Name, and Sort by IP Address

Sort Horizontally โ€” Sort Left to Right by Row

By default, Excel sorts top to bottom โ€” it rearranges rows. But sometimes your data runs horizontally, and you need to sort columns left to right based on values in a specific row. Think of a monthly budget spreadsheet where Jan, Feb, Mar are columns and you want to reorder them by total spend.

Here's how to sort horizontally in Excel:

  1. Select the entire data range including any row you want to use as the sort key.
  2. Go to Data tab โ†’ Sort.
  3. Click the Options button in the top-right of the dialog.
  4. Under Orientation, select Sort left to right. Click OK.
  5. In the Row dropdown, choose the row whose values will control the column order.
  6. Set Order to Smallest to Largest (or A to Z for text). Click OK.

Important: this option isn't sticky โ€” Excel resets to Sort top to bottom every time you open the dialog. You have to set Sort left to right manually each time.

Sort by Name โ€” First Name vs Last Name

Sorting a name column when names are in "First Last" format is straightforward โ€” sort the column A to Z and it sorts by first name. But if you need to sort by last name, you first need to split the column.

Use Text to Columns (Data tab โ†’ Text to Columns โ†’ Delimited โ†’ Space) to split first and last names into separate columns. Then sort by the last name column. Alternatively, use formulas: =MID(A2,FIND(" ",A2)+1,100) extracts the last name portion from a "First Last" format for a helper column.

For the excel sort function approach โ€” =SORT() combined with =SORTBY() โ€” you can sort a full name table by a helper column without ever touching the original data.

Sort by IP Address โ€” The Lexicographic Problem

IP addresses look like numbers but are stored as text in Excel. Text sorting compares character by character, so 192.168.1.10 sorts before 192.168.1.9 because 1 (first character of 10) is less than 9. That's wrong for numeric IP ordering.

Workaround: helper columns. Split the IP into four octets using TEXTSPLIT() (Excel 365) or nested MID()/FIND() formulas. Convert each octet to a number. Sort by Octet1, Octet2, Octet3, Octet4 as four separate levels in the Custom Sort dialog. Delete helper columns after sorting.

Power Query approach: Load data into Power Query โ†’ Add Column โ†’ Custom Column for each octet using Number.From(Text.BeforeDelimiter([IP], ".", 0)) etc. โ†’ Sort by all four columns โ†’ Close and Load. This is reproducible and can be refreshed when data updates.

Neither approach is quick. IP address sorting is one of the less elegant corners of Excel โ€” it's functional, but it takes real setup time.

Sorting with the Excel SORT Function vs Helper Columns

When you need to sort data that changes frequently โ€” like a live sales feed or a regularly updated inventory list โ€” the dynamic excel sort function eliminates the need to re-sort manually. You write the formula once, and the output always reflects the current sort order of the source data. Combine it with FILTER to show only rows that meet a condition, sorted by a specific column: =SORT(FILTER(A2:D100, D2:D100>"100"), 2, 1) โ€” filter to rows where column D > 100, then sort by column B ascending.

For simpler one-time sorts โ€” especially on static data โ€” the Sort dialog is faster and more intuitive. Most users don't need the SORT function until they're building dashboards or reports that auto-refresh. For everyday column-sorting tasks, Alt + A + S + A and the Data tab buttons are all you need.

Also worth knowing: if you use excel pivot tables to summarize data before sorting, pivot tables have their own built-in sort options per field โ€” right-click any row or column label in the pivot to access Sort and field-specific sorting settings. This is separate from the regular worksheet sort and operates on the pivot's internal data model.

Before You Sort: Excel Checklist

Remove merged cells โ€” merged cells break sorting and cause an error dialog. Unmerge all cells in the sort range first (Home โ†’ Merge & Center โ†’ Unmerge Cells).
Check for hidden rows and columns โ€” hidden rows sort along with visible ones, which can produce unexpected results. Unhide all rows before sorting.
Convert text-formatted numbers โ€” if numbers are left-aligned or have a green corner triangle, convert them (click warning icon โ†’ Convert to Number) before sorting.
Make sure headers are in Row 1 โ€” the Custom Sort dialog assumes your header row is at the top. Blank rows above the headers confuse the dialog.
Remove or fill blank rows inside your data โ€” a completely blank row signals Excel that the dataset has ended. Rows below the blank won't sort.
Check that all data types are consistent per column โ€” mixing numbers and text in the same column produces unreliable sort order.
Turn off any active filters โ€” active filters can hide rows, making the sort appear incomplete. Clear filters (Data โ†’ Clear) before sorting.
Save a backup โ€” sorting is not easily undone if you have a large dataset and close the file. Ctrl+Z works within the session, but not after saving.

Excel Sorting Not Working โ€” 5 Common Causes and Fixes

You click Sort A to Z and nothing happens, or the order looks random, or some rows don't move. It's one of the more puzzling Excel experiences because the button gives no error โ€” it just doesn't sort correctly. Here are the five causes that account for the vast majority of sorting failures.

1. Merged Cells in the Sort Range

This is the #1 culprit. Merged cells physically span multiple rows or columns, making it impossible for Excel to reorder individual rows. You'll usually see a dialog that says: "To do this, all merged cells need to be the same size."

Fix: select your entire dataset, go to Home โ†’ Merge & Center dropdown โ†’ Unmerge Cells. Re-enter data into the cells that were left blank by the unmerge, then sort. Alternatively, format the appearance using Center Across Selection (Format Cells โ†’ Alignment โ†’ Horizontal: Center Across Selection) โ€” it looks merged but isn't.

2. Numbers Stored as Text

Excel left-aligns anything stored as text. If your "number" column left-aligns, sort by number will produce wrong order: 1, 10, 100, 2, 20, 200. The character-by-character text comparison isn't the sort order you want.

Fix: select the column, look for the green corner triangle warning โ†’ click the icon โ†’ Convert to Number. Or: paste a blank cell over the column using Paste Special โ†’ Multiply to force numeric conversion. Then sort again.

3. Hidden Rows Disrupting the Sort

Hidden rows participate in sorting โ€” they get reordered along with visible rows. If rows are hidden via filter, the hidden rows may get shuffled into different positions when you sort, causing apparent data loss or mismatches when you unhide.

Fix: clear all filters first (Data โ†’ Clear), unhide all rows (Ctrl + Shift + 9), then sort. Re-apply your filter after sorting.

4. Data Range Not Fully Included

If you click a cell at the edge of your data and Excel doesn't recognize the full range, only part of the dataset gets sorted. This is most likely when there are blank columns or rows that break the contiguous block.

Fix: manually select the entire range before opening the Sort dialog. Include all columns you want to participate in the sort. Check that row 1 is your header row โ€” if it isn't, uncheck My data has headers in the Sort dialog.

5. Filter Is Still Active (Partial Sort)

An active filter hides rows. When you sort with a filter active, Excel only sorts the visible rows โ€” hidden rows stay in their original positions. When you clear the filter later, the hidden rows reappear in their original positions, breaking the sort you just did.

Fix: Data โ†’ Clear to remove all active filters, then sort. Re-apply the filter afterward. For consistent results on advanced excel skills workflows, convert your range to a Table (Ctrl + T) โ€” Table sort and filter work together cleanly without this problem.

Also check whether excel sortable columns are properly defined in your Table โ€” Table headers automatically get filter dropdowns, and sorting via those dropdowns always includes all table rows.

Workflow: Setting Up a Complex Multi-Column Sort

1

Decide which columns will control sort order and in what priority. Primary key (e.g. Region), secondary key (e.g. Revenue), tertiary key (e.g. Name). Write them down โ€” it's easy to lose track once you're inside the dialog.

2

Run through the Before-You-Sort checklist: unmerge cells, unhide rows, convert text numbers, remove blank rows, clear active filters. Skipping this step is the most common reason multi-column sorts produce wrong results.

3

Click any cell inside the data range. Go to Data tab โ†’ Sort (the full dialog, not the quick A-Z buttons). Confirm My data has headers is checked if you have a header row.

4

Set the primary sort level: Sort by โ†’ your first column, Values, and your desired order. Click Add Level for each additional key. Drag levels up or down to change priority. Delete any levels you don't need.

5

For text columns: A to Z or Z to A. For number/date columns: Smallest to Largest or Largest to Smallest. For custom order (e.g. High/Medium/Low): choose Custom List in the Order dropdown and define your sequence.

6

Review all levels in the dialog โ€” order, column, sort type. Click OK. Excel applies all levels simultaneously in one pass.

7

Scroll through the sorted data. Check that rows stayed together (no row-level scrambling). Verify the sort order in each key column is correct. If anything looks off, press Ctrl+Z immediately to undo โ€” before saving.

Excel Sort: Quick Stats

3
Sort orders available
64
Max sort levels
365+
SORT function availability
Alt+A+S+A
Ascending shortcut

SORT Function (Dynamic) vs Sort Dialog (Static)

Pros

  • Updates automatically when source data changes โ€” no re-sorting needed
  • Non-destructive โ€” original data stays untouched
  • Composable with other functions like FILTER, UNIQUE, and SORTBY
  • Can be nested inside other formulas for complex data transformations
  • SORTBY lets you sort by a column that's not even part of the output range

Cons

  • Requires Excel 365 or 2021 โ€” unavailable in older versions
  • Output spill range is read-only โ€” can't manually edit sorted values
  • Needs empty destination cells โ€” causes #SPILL! error if any are occupied
  • Formula syntax is unfamiliar to casual Excel users
  • Harder to explain to colleagues who just see a plain data range
Test Your Excel Knowledge

Excel Questions and Answers

How do I sort a column in Excel?

Click any cell in the column you want to sort. Go to the Data tab and click Sort A to Z (ascending) or Sort Z to A (descending). If your column has related data in adjacent columns, choose Expand the Selection when prompted so entire rows stay together. Keyboard shortcut: Alt + A + S + A for ascending, Alt + A + S + D for descending.

What is the sort shortcut in Excel?

The main Excel sort shortcut keys are Alt + A + S + A (sort ascending, A to Z or smallest to largest) and Alt + A + S + D (sort descending, Z to A or largest to smallest). Press each key in sequence. Ctrl + Shift + L toggles the filter/sort dropdowns on column headers, giving you sort access without opening the ribbon. Alt + D + S opens the full Sort dialog in older Excel versions.

How do I sort multiple columns in Excel?

Use the Custom Sort dialog: click inside your data, go to Data tab โ†’ Sort (the full dialog button). Check My data has headers. Set your primary sort column in the first level. Click Add Level and set your secondary column. Add more levels as needed โ€” up to 64. Set the order (A to Z, Z to A, Smallest to Largest, etc.) for each level. Click OK to apply all levels at once.

Why is Excel sorting not working?

The five most common causes: (1) merged cells in the sort range โ€” unmerge them first; (2) numbers stored as text โ€” convert them via the warning icon; (3) hidden rows mixed into the sort โ€” unhide all rows and clear filters before sorting; (4) incomplete data range selected โ€” manually select all columns; (5) active filter applied โ€” clear filters before sorting so all rows are included.

How do I sort alphabetically in Excel?

Click any cell in the text column you want sorted. On the Data tab, click Sort A to Z (the AZโ†“ icon). That sorts the column from A to Z, keeping related row data together if you choose Expand Selection when prompted. Shortcut: Alt + A + S + A. Right-click method: right-click the cell โ†’ Sort โ†’ Sort A to Z.

How do I sort by number in Excel?

Click any cell in the number column. Go to Data tab and click Sort Smallest to Largest (the number sort version of Sort A to Z) or Sort Largest to Smallest. The shortcut is still Alt + A + S + A for ascending and Alt + A + S + D for descending. Make sure numbers aren't stored as text โ€” left-aligned numbers or green corner triangles indicate a text format that will sort incorrectly.

Can you sort horizontally in Excel?

Yes. Select your data range, go to Data tab โ†’ Sort โ†’ click Options โ†’ select Sort left to right. Then choose which row number to sort by in the Row dropdown. Set your order and click OK. This reorders columns based on the values in that row. Note that Excel resets to top-to-bottom sorting every time you open the dialog โ€” you must set Sort left to right manually each use.

What is the SORT function in Excel?

The SORT function is a dynamic array formula available in Excel 365 and Excel 2021. Syntax: =SORT(array, sort_index, sort_order, by_col). It returns a sorted copy of the source range that updates automatically when data changes. sort_index is the column number to sort by (default 1). sort_order is 1 for ascending (default) or -1 for descending. by_col is FALSE to sort rows (default) or TRUE to sort columns. For multi-key sorting, use SORTBY instead.
Practice Excel Questions
โ–ถ Start Quiz