Calculation Issues

Sort Hierarchical Numbers in Excel Correctly

Algirdas JasaitisAlgirdas Jasaitis Dec 2, 2026 869 views

Question details

Sort labels such as 1.1, 1.2, and 1.10 by their numeric hierarchy rather than as text.

How to Sort Hierarchical Numbers in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains two-part hierarchical labels that need to be sorted by major and minor number.
Observed behavior
Text sorting places 1.10 before 1.2 because it compares characters rather than the numeric parts of each label.
Before you start

Check that the labels are stored as text and each has two nonnegative integer parts separated by a period. If Excel already converted 1.10 to the numeric value 1.1, restore the original label as text before sorting; the lost trailing zero cannot be recovered from the number alone.

Solution 1Recommended

Sort by separate major and minor number columns

Use two numeric helper columns to sort two-part labels while keeping the original labels unchanged.

1
Add helper columns

Add columns named Major and Minor next to the labels. For these examples, assume the first label is in A2.

2
Extract the major number

In the Major cell for row 2, enter =--LEFT(A2,FIND(".",A2)-1), then fill the formula down alongside all labels.

3
Extract the minor number

In the Minor cell for row 2, enter =--MID(A2,FIND(".",A2)+1,LEN(A2)), then fill the formula down alongside all labels.

4
Sort both columns

Select the entire data range, including the helper columns, and choose Data > Sort. Select Major and Smallest to Largest, then choose Add Level and sort Minor from Smallest to Largest. Confirm with OK.

Labels with leading zeros: The numeric sort treats minor parts such as 01 and 1 as equal. The original labels remain unchanged, but their relative order is not determined by these two keys.
Sort hierarchy labels in WPS Spreadsheets

Sort Hierarchical Numbers in WPS Spreadsheets

Use numeric helper columns and a multi-level sort in WPS Spreadsheets to arrange two-part labels without changing their displayed text.

  1. 1. Open the worksheet: Open your Excel workbook in WPS Spreadsheets and check that the two-part labels are stored as text.
  2. 2. Create numeric helpers: Add Major and Minor columns. If the first label is in A2, enter =--LEFT(A2,FIND(".",A2)-1) for Major and =--MID(A2,FIND(".",A2)+1,LEN(A2)) for Minor, then fill both formulas down.
  3. 3. Sort the full range: Select the full data range and open Data > Sort. Sort Major from smallest to largest, add a level for Minor in the same order, and apply the sort.
Sort major and minor parts numericallyKeep original hierarchy labels visibleOpen and save Microsoft Excel XLSX filesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel sort 1.10 before 1.2?

When the labels are text, Excel compares characters from left to right. Use numeric Major and Minor helper columns and sort by both under Data > Sort.

Can I recover 1.10 if Excel changed it to 1.1?

Not from the numeric value alone: Excel stores 1.10 and 1.1 as the same number. Restore the original label from the source, format the destination cells as Text using Home > Number Format, and reenter or import the labels.

Will these formulas work for labels such as 1.2.3?

No. The formulas are for labels with exactly two integer parts. For three-part labels, extract each part into a separate numeric helper column and add a sort level for each column.

Can I hide the helper columns after sorting?

Yes. Select the helper column headers, right-click, and choose Hide. The sorted rows and original labels remain visible.