Utility · Apr 15, 2026 · Updated Oct 13, 2026 · 3 min read

The Complete Guide to Sorting Text Lines

Alphabetical, natural and numeric sorting disagree on the same list. Measured against GNU sort: natural order puts -5 before -10 and 10.5 before 10.25, case-sensitive sorting is not ASCII order, and our shuffle now uses crypto randomness.

Three Different Things Called "Sorting"

Alphabetical, natural and numeric order disagree on the same list. We ran one list through each mode of our Sort Lines tool and through GNU sort (October 2026; results in our test folder):

InputAlphabetical (A-Z)Natural (1-9)Number value (like sort -g)
Item 2, Item 10Item 10, Item 2Item 2, Item 10—
v1.2, v1.10, v2.0v1.10, v1.2, v2.0v1.2, v1.10, v2.0—
-5, -10, 0.25, .5, 10.25, 10.5-10, -5, .5, 0.25, 10.25, 10.5 (by characters)-5, -10, .5, 0.25, 10.5, 10.25-10, -5, 0.25, .5, 10.25, 10.5
1e3, 9991e3, 9991e3, 999999, 1e3

Natural order compares runs of digits as numbers, which is right for file names and versions, but it reads - and . as plain characters, so it puts -5 before -10 and 10.5 before 10.25. For actual numbers (prices, measurements, scientific notation) use the number-value mode, which matched GNU sort -g on all 24 lines of our test list.

What "Alphabetical" Means in Practice

The tool compares with the browser's Intl.Collator, the Unicode collation algorithm for your language, not character codes. So accented letters sort beside their base letter in English (e, é, f; n, ñ, o), but in Swedish å, ä and ö come after z, as they do in that alphabet. Two people with different browser languages can get different orders for the same list.

Case: by default upper and lower case are treated alike. With case-sensitive sorting on, the order is still dictionary order with case as a tie-break (apple, Apple, B, banana, Cherry in our test), not the ASCII order of some command-line tools, where every capital comes before every lowercase letter. For ASCII order, use LC_ALL=C sort.

Length, Reverse and Shuffle

Ties Keep Their Order

Lines that compare equal stay in their original order, because JavaScript's sort has been required to be stable since ECMAScript 2019, and the column and ignore-prefix options add the original position as an explicit tie-breaker. That makes multi-pass sorting work: sort by the secondary key first, then by the primary key.

Try the tool

8 sort modes, international support, runs in your browser.

Open Sort Lines →

Frequently Asked Questions

Why does '10' sort before '2' alphabetically?
Character-by-character sorting reads '1' before '2', so '10' (starting with 1) comes before '2'. Switch to numerical/natural sort to treat number sequences as actual numbers.
Does it handle international characters?
It uses your browser's Unicode collation for your language, so accented letters sort with their base letter in English, while Swedish puts å, ä and ö after z. The same list can therefore sort differently in different browser languages.
Is shuffle cryptographically random?
Yes, since October 14, 2026: the shuffle draws from crypto.getRandomValues() with rejection sampling, and a 240,000-run test showed every order equally likely. It used Math.random() before, which is predictable.
Can I sort by multiple criteria?
Yes, in passes: sorting is stable, so sort by the secondary key first (for example the first name, using the column option), then by the primary key (the last name). Lines that tie on the primary key keep the order from the first pass.

Published Apr 15, 2026 · Updated Oct 13, 2026 by Derek Giordano

📚 References & Further Reading
Browse all utility tools →
⚡Sort Lines Alphabetically→
GuideHow to Remove Duplicate Lines from Any Text→UtilityHow AI Text Detection Works→CSSCSS Text Effects: Gradients, Shadows & Transforms→GuideHow Fancy Text Works (And When Not to Use It)→ContentHow to Analyze Text Readability and Word Count→ContentHow to Convert Text Case: Uppercase, Lowercase, Title Case→ContentHow to Count Words and Characters in Text→CSSHow to Create a CSS Text Gradient (Color Text Effect)→