Sort lines
Client-side only. Sort runs in this tab. Nothing is uploaded.
When line order is the bug
You already have the values. The paste is just out of order: filenames in a PR checklist, hosts from two scans, tags from a dump, or bullets you want alphabetical before you commit. Paste the list, pick a mode, hit Sort, copy the result.
This page reorders whole lines in the browser. It does not parse CSV columns, run SQL, or sync with a sheet.
Sort modes compared
| Mode | What it does | Best for |
|---|---|---|
| A–Z | Alphabetical ascending (localeCompare) | Names, tags, plain word lists |
| Z–A | Alphabetical descending | Reverse dictionary order |
| Reverse order | Flips the current line order. No alpha sort | Undoing a bad paste order, last-to-first logs |
| Natural | Numeric-aware: digit runs compare as numbers | file1 / file2 / file10, host-2 / host-10 |
Plain A–Z vs natural sort
Leave the sample paste. With Natural and default options (case off, trim on, ignore empty), the filename block should land as:
file1.txt file2.txt file10.txt
Switch to A–Z and re-run. Plain string sort often puts file10.txt before file2.txt because 1 beats 2 at the first differing character. That is why natural mode exists for versioned filenames and numbered hosts.
With case sensitive off, Apple and apple sit next to each other under a case-insensitive key. The output still shows the original spelling of each kept line.
Options that change the result
- Case sensitive (default off): off folds for compare only. On treats
Appleandappleas different keys. - Trim before compare (default on): leading and trailing spaces are ignored for ordering and for dedupe keys. Output lines keep their original text unless you trimmed them into empties that get skipped.
- Ignore empty lines (default on): blank rows are dropped and counted under Empties skipped.
- Remove duplicates after sort (default off): after ordering, the first line for each compare key is kept. Turn this on when you want a sorted unique list in one pass.
Limits
- Whole-line sort only. No multi-column CSV awareness, no locale custom collation beyond the browser default, no fuzzy match.
- Reverse mode does not alphabetize. It only flips the current sequence (after empty skips if that option is on).
- Very large pastes are limited by tab memory. Multi-million-row files belong in a local script or database ORDER BY.
- Refresh clears the boxes. Copy the result out if you need it later.
- Pair with duplicate line checker when you need unique lines without sorting, word counter for length checks, case converter or camel case converter for a uniform casing pass first.
FAQ
Does sorting upload my text?
No. Sorting runs in JavaScript in this tab. ToolPetal has no server step for the sort lines tool.
What is natural sort?
Natural (numeric-aware) sort compares digit runs as numbers, so file2.txt comes before file10.txt. Plain A–Z treats them as character strings, so file10.txt often sorts before file2.txt.
Is case sensitive on by default?
No. Case sensitive is off by default so Apple and apple group together under a friendlier alpha order. Turn it on when you need uppercase and lowercase treated as different keys.
Does remove duplicates keep first or last?
After the chosen sort, duplicates are collapsed in the sorted order and the first occurrence of each compare key is kept. Compare keys still respect case and trim options.