GUIDE · LISTS
Sorting lines and when ordering helps
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. This guide explains what line sorting actually compares and when you are better served by reversing the list instead.
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:
- Numbers as text. Line-based sorting compares text, not arithmetic. A list containing
2,10,100sorts as10, 100, 2, because "1" precedes "2" character by character. Zero-pad numbers (002,010,100) if you need numeric order from a text sort. - Accented and non-English letters. Where
é,ñorüsit in the sequence depends on locale conventions. Two browsers set to different languages can order the same list differently. Neither is wrong; both are locale-specific. - Punctuation and case. Symbols and capitalization affect position. If a sorted list looks slightly off, normalize case first and check whether leading punctuation marks are pushing entries around.
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 or a reading order should not be alphabetized — it should be reversed at most. Reverse line order exists for exactly these cases: it flips 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.
A sequence that avoids surprises
- Confirm one item per line. Sorting operates on whole lines, so a wrapped entry becomes two sorted fragments.
- Normalize if the list is mixed. Clean spacing and, if appropriate, a single case conversion make the ordering consistent.
- Pick the operation. Sort lines A–Z for lookup lists, Reverse line order for chronological or intentional sequences.
- Spot-check the top and bottom. Order errors concentrate at the boundaries — the first and last few lines reveal most problems.
When to sort, when not to
Sort when the list is a lookup: names, titles, identifiers, options in a menu. 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.
← All guides