TT · TEXT TIDY

GUIDE · LISTS

Sorting lines and when ordering helps

By ShengFeng · Published 2026-09-26 · Last updated: 2026-10-14

Sorting a list alphabetically feels trivial, and for a column of plain words it usually is. But the moment numbers, punctuation, accents or mixed scripts appear, ordering stops being universal and starts being a convention. This guide explains what line sorting actually compares, where it quietly surprises people, and when you are better served by reversing the list instead of sorting it.

What alphabetical really means

Sorting here uses the ordering rules built into your browser's locale, comparing strings character by character. That produces predictable results for a simple list, but three traps come up constantly:

This particular tool compares with sensitivity set to base, which means case and accent marks are ignored during the comparison. Apple and apple compare as equal, and resume and résumé compare as equal too. When two entries compare as equal, the browser keeps them in the order they arrived, so the result is stable rather than arbitrary.

Before and after

A list of filenames as it arrives from an export, then sorted:

before:
  report_final.docx
Budget 2026.xlsx
agenda.md

after Sort lines A–Z:
agenda.md
Budget 2026.xlsx
report_final.docx

Two things to notice. The leading spaces are still there, because sorting compares whole lines and never trims them — run Clean spacing first if you want the comparison to ignore padding. And Budget sorted between agenda and report because the comparison is case-insensitive, which is what most people expect from a filename list.

Numbers: why 10 sorts before 2

This is the surprise that generates the most complaints, and it is not a bug. Text comparison walks character by character: 10 and 100 both start with 1, so they sort before 2, and 100 sorts before 10 because its second character 0 precedes the end of the shorter string.

Text order versus numeric order
Input Text sort result Numeric order Fix
2, 10, 100 10, 100, 2 2, 10, 100 Zero-pad: 002, 010, 100
Chapter 1–10 Chapter 1, Chapter 10, Chapter 2 Chapter 1, Chapter 2, Chapter 10 Zero-pad the number: Chapter 01
v1.9, v1.10 v1.10, v1.9 v1.9, v1.10 Zero-pad the minor version: v1.09

Zero-padding is the general fix: make every number the same width with leading zeros, sort, and then remove the padding if you need the original form back. It is a small amount of preparation that turns a text sort into a numeric one, without needing a different tool.

Why the same list can sort differently on two machines

Sorting is locale-aware, which means the browser consults the language it has been told to use. Two people on the same operating system with different language settings can therefore get different results from the same list, and neither result is a bug. The differences show up in three places: where accented letters sit relative to their unaccented forms, how punctuation is weighted, and how letters outside the English alphabet are placed.

The practical implication is that a sorted list is not a portable artefact. If the order matters — because it will be printed, compared or imported somewhere else — sort it, then treat the sorted output as the record rather than relying on a later sort to reproduce it. If you need the same order everywhere, normalize the text so that the comparison cannot differ: fix the case, strip accents, and zero-pad numbers. A normalized list sorts identically wherever it is opened.

Using a sort as a review step

One of the most useful things a sort does has nothing to do with the final order. Sorting brings similar entries next to each other, which makes inconsistencies visible in a way an unsorted list never does. Sort a list before you review it and the near-duplicates that differ by a trailing space become obvious, along with the tag that appears once with a capital letter and the entry that was typed twice with slightly different wording. None of those are caught by exact duplicate removal, and all of them are easy to spot once the list is in order.

Read the sorted list, decide what to fix, and then decide whether the sorted order itself is what you want to keep. If it is not, the original input is still sitting in the input panel untouched, because nothing here modifies what you pasted.

Sorting is not the only ordering task

Many lists arrive newest-first or in the order things were added, and that order is the point. A journal, a changelog, a set of instructions or a reading order should not be alphabetized — at most it should be reversed. Reverse line order exists for exactly these cases: it flips the list top to bottom without touching the content of any line, which preserves a chronological or intentional sequence while letting you read it the other way around. The sort-versus-reverse guide works through the decision.

A sequence that avoids surprises

  1. Confirm one item per line. Sorting operates on whole lines, so a wrapped entry becomes two sorted fragments.
  2. Clean spacing first. Trimming each line removes the padding that would otherwise change the comparison.
  3. Normalize case if the list is mixed. A single case conversion makes the ordering easier to predict and to check.
  4. Zero-pad any numbers that should sort numerically rather than as text.
  5. Pick the operation. Sort lines A–Z for lookup lists, Reverse line order for chronological or intentional sequences.
  6. Spot-check the top and bottom. Order errors concentrate at the boundaries — the first and last few lines reveal most problems.

When to sort, and when not to

Sort when the list is a lookup: names, titles, identifiers, options in a menu, files in a folder. A sorted list is faster to scan and easier to search by eye. Do not sort when the list tells a story in time, when rows are paired positionally with content elsewhere, or when the input is prose that merely looks line-based. When in doubt, sort a copy and compare — a wrong sort is easy to make and quiet in its effects, because the content all survives while the meaning quietly shifts.

Frequently asked questions

Why does 10 come before 2?

Because the sort compares text, not numbers. Both 10 and 100 begin with the character 1, which sorts before 2. Zero-pad your numbers — 002, 010, 100 — if you need numeric order.

Is the sort case-sensitive?

No. The comparison ignores case and accent marks, so Apple and apple are treated as equal and keep their original relative order. To force a particular case grouping, normalize the case before sorting.

Does sorting remove duplicates?

No. Sorting only changes order. Duplicate lines end up next to each other, which makes them easier to spot, but you need Remove duplicate lines to actually delete them.

Will sorting break lines that contain commas?

It will not split them, but it will sort by the whole line including everything after the comma. If a line holds several fields, normalize the data into one field per line first.

← All guides