Line Sorter
Sort lines A–Z, Z–A, natural numeric (1–10), shortest-to-longest, or longest-to-shortest with optional duplicate removal, trimming, and blank-line filtering.
How to Use
- Paste or type your lines into the Input lines pane (or click Sample to load sample headings).
- Click any sort chip: A → Z, Z → A, Natural Numeric (1→10 or 10→1), Shortest → Longest, or Longest → Shortest.
- Adjust Remove duplicates, Trim lines, Skip blank lines, or Case-sensitive checkboxes as needed.
- Click Copy to copy the sorted lines or Reset to clear the tool.
What is Line Sorter?
A line sorter rearranges newline-separated lists into clean, predictable sequences—whether alphabetical, reverse alphabetical, natural numeric, or ordered by character length—while cleaning duplicate or blank lines. Programmers, marketers, and spreadsheet users rely on line sorting to organize config keys, domain lists, keyword tables, and outline items without leaving the browser.
How It Works
The `sortLines` helper splits your text by newlines (`\r?\n`), trims leading and trailing spaces if enabled, filters out empty rows, deduplicates matching entries when Remove duplicates is checked, and sorts the remaining rows live using `Intl` locale collation, natural numeric collation (`numeric: true`), or string `.length` comparisons.
Common Use Cases
- Tidying code imports, CSS rules, or host blocklists — sort rows A–Z and strip duplicate entries simultaneously
- Organizing numbered outline sections — keep "Section 2" before "Section 10" with Natural Numeric (1→10) sorting
- Finding shortest or longest labels — rank lines by character length to spot outliers before database imports
- Preparing unique mailing or SKU lists — normalize whitespace, skip blank rows, and remove duplicates locally
Technical Details
Powered by `sortLines` (delegating to `sortTextLines`) with 6 `LineSortMode` options (`az`, `za`, `natural-asc`, `natural-desc`, `length-asc`, `length-desc`), configurable `deduplicate`, `trimLines`, `ignoreEmpty`, and `caseSensitive` flags, live line/duplicate metrics, Sample, CopyButton, and ResetButton.
FAQ
Which sorting modes does Line Sorter offer?
Line Sorter includes six one-click sorting chips: A → Z, Z → A, Natural Numeric (1→10), Natural Numeric (10→1), Shortest → Longest, and Longest → Shortest.
Can I keep duplicate lines instead of removing them?
Yes. Uncheck Remove duplicates to preserve repeated lines while sorting, or keep it checked to deduplicate automatically.
Does Line Sorter treat uppercase and lowercase differently?
By default sorting and deduplication are case-insensitive (base sensitivity). Enable Case-sensitive if you want exact case distinctions during sorting and duplicate checks.
Is Line Sorter private and free?
Yes. Every operation executes locally in your browser with no server upload or signup.