Sort Lines
Sort any list alphabetically, naturally, numerically, by length, or shuffle it — locale-aware and stable, entirely on this device.
Stable sort — lines with equal keys keep their input order.
Press ? for shortcuts
Do it offline:$ sort file.txt
How to use it
- Paste your list, or drop a .txt or .csv file onto the input — one entry per line, read entirely on this device.
- Pick a mode: alphabetical, natural, numeric, length or random. The A → Z / Z → A switch applies to every mode except random.
- Tune the comparison — collation locale, exact case matching, trimming before comparing, or removing duplicate lines first.
- Copy the result, download it as .txt, or share the tool state as a link once you have checked it holds nothing sensitive.
Put any list in order without sending it anywhere: alphabetically under real locale collation, naturally so file2 lands before file10, numerically by value, by line length, or shuffled. Every mode is a pure permutation of your lines — nothing gets rewritten on the way through — and large lists run in a background worker up to the 32 MB cap.
How it works
Alphabetical and natural modes delegate comparison to the browser's Intl.Collator, an implementation of the Unicode Collation Algorithm with per-language tailorings. The letters never change — only the rules do, which is why Ärger files between Anfang and Zug under German collation yet after Zug under Swedish. Case differences are ignored by default while accents still count; the case-sensitive toggle raises the collator to full strictness.
Natural mode is the identical collator constructed with numeric: true — each run of consecutive digits inside a line is compared as one number rather than character by character, so file2 precedes file10 with no zero-padding. In every deterministic mode the final tiebreak is the line's original position — the single rule that keeps the sort stable in both directions.
Examples
file10
file2
file1file1
file2
file10Digit runs compare by value, so 2 comes before 10 — contrast the alphabetical pass over the same names below.
file2
file1
file10file1
file10
file2Character by character, the 1 in file10 beats the 2 in file2 — right for dictionary words, wrong for filenames.
Ärger
Anfang
ZugAnfang
Ärger
ZugGerman collation treats Ä as a variant of A, so Ärger files second, between Anfang and Zug.
Zug
Ärger
AnfangAnfang
Zug
ÄrgerSwedish ranks Ä as its own letter past Z — the same three words as above, a different national ordering.
3.14
-2
1,000
n/a
0.5
total-2
0.5
3.14
1,000
n/a
totalFloats, negatives and comma-grouped thousands sort by value; the two lines that are not numbers sink to the end in their original order, and a notice counts them.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Descending is not a reversed ascending
Lines with equal keys keep their input order in both directions: b, B, a sorts to a, b, B going up and b, B, a going down. Reversing the ascending output would flip that tie.
Blank lines lead the ascending order
An empty line compares before any text: blanks gather at the top going up, at the bottom going down. They are real lines; remove-duplicates keeps only the first.
What numeric mode accepts as a number
Each line is trimmed, comma grouping of the strict 1,234 shape is stripped, and the rest goes through JavaScript's Number(): floats, negatives, exponents like 2e3, Infinity and hex like 0x10 all parse. An empty line is never read as zero.
Mixed line endings come out uniform
The output joins with the input's most common terminator — on a tie, the one seen first — and a chip says which won. A trailing newline survives.
Emoji and CJK order follows the locale
Collation modes rank every character through the chosen locale's tailoring, not raw code-point values — 漢字 and 😀 land where its rules put them.
Length mode counts code points
An astral emoji counts as one; a family emoji assembled from joiners counts each joined code point, not one grapheme.
A shared random link deals a fresh order
Share links carry the tool state but never the shuffle seed — each open draws a new one. To pass on a fixed order, share the shuffled output itself.
Common errors
14 lines are not numbers — placed last, original order kept- Numeric mode never blocks on prose mixed into the figures: headers and footnotes sink below the sorted numbers unchanged, and this notice counts them.
Input is larger than the 32 MB limit for this tool. For bigger payloads use the CLI: sort file.txt- A typed refusal, never a truncation — below the cap the page sorts everything, above it nothing. The named coreutils command orders any file size in the terminal.
This looks like a binary file, not text — choose a text file instead.- Dropped files are sniffed for NUL bytes before being read as lines; a refusal leaves the current input untouched.
FAQ
When is natural sort the right choice over alphabetical?
Whenever digit runs carry meaning: filenames, versions, invoice or ticket numbers. Natural mode reads file2 and file10 as the values 2 and 10; alphabetical reads them as characters and interleaves them. On digit-free text the modes agree.
Two lines compare as equal — which one wins?
Neither moves past the other: the earlier line stays earlier, ascending or descending. With case matching off, README and readme form such a tie; case sensitivity and trimming change what counts as equal, never the tie rule.
Does my list stay on this device, and why does a shared shuffle differ?
Sorting runs in your browser and no line is transmitted. A share link encodes the tool state in the URL fragment, which browsers never send to servers; the seed is left out, so a random-mode link deals a new arrangement on every open.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Re-run the sort at any input size.
- ⌘/Ctrl + S
- Download the sorted list as a .txt file.
- ⌘/Ctrl + C
- Copy the whole output while nothing is selected; a selection copies normally.
- ⌘/Ctrl + Shift + C
- Copy the whole output even while a selection exists.
- t
- Advance to the next color theme.
- ? or ⌘/Ctrl + /
- Open the shortcut help dialog.
- Esc
- Dismiss the topmost dialog; the input always stays.