Excel — mixed text/number sorting

Can't sort this column in Excel — hidden spaces and text-numbers cause

You sort the column and some values land in the wrong order, or all the way at the bottom regardless of their size. Excel sorts numbers and text-that-looks-like-numbers as two separate groups — and a leading or trailing space changes which group a value falls into. Drop your file in below to see which cells are the odd ones out.

clean-export · xlsx-for-ai

Excel sorts by data type first, value second

An ascending sort in Excel doesn't just compare values — it groups by type first: numbers, then text, then logical values, then errors, always in that order (descending just reverses each group's internal order, but numbers still cluster separately from text). A column that looks like a clean list of numbers can actually be a mix of real numbers (right-aligned by default) and numbers stored as text (left-aligned, often flagged with a small green triangle in the corner). Sort it, and every text-number sinks to the bottom of the column — or the top of a descending sort — as a block, regardless of its numeric value.

Where the text-numbers come from

This almost always traces back to how the data arrived: values pasted from a web page or PDF, imported from a CSV where a column had a leading zero or a plus sign that made Excel default it to text, or entered with a leading apostrophe at some point to "protect" the formatting. Once a cell is text, typing a formula-visible number into it doesn't convert it — the underlying type stays text until it's explicitly converted.

The hidden-space complication

Even among genuinely text values, a cell with a trailing space — a regular space or, more stubbornly, a non-breaking space (Unicode character 160, common in data copied from websites) — sorts differently than the same text without it, because sorting compares strings character by character and a space is a real character in that comparison.

How to fix it

Select the column, use Data → Text to Columns → Finish (with no delimiter changes) to force text-numbers back into real numbers in one pass, and separately run TRIM/CLEAN or Find & Replace to strip stray spaces. Upload your file above first and the checker will flag exactly which cells in the column are text-typed versus numeric, and which carry leading or trailing whitespace.

More Clean up a messy Excel export — free. guides

← All Clean up a messy Excel export — free. guides