Skip to content
TypeParser
All tools

Sort Lines

Sort lines alphabetically or numerically.

beats textmechanic.com edge: Numeric + locale-aware
input
Guide

About Sort Lines

Sort lines alphabetically (Unicode order or locale-aware), numerically (8 vs 80 vs 800 the right way), by length (shortest to longest), or reverse any of the above. Case-insensitive optional. Useful for cleaning lists, ordering imports, organizing config files.

When sorting matters

Sorting brings order; ordered data dedups, diffs, and grep cleanly. Common cases:

  • Order imports — alphabetical by package name
  • Sort an export — for stable diff between exports across runs
  • Build a sortedset — alphabetical with case-insensitive optional
  • Stable test fixtures — sorted input gives predictable test snapshots

Numerical caveat

Most “natural” sort tools handle the 8.txt / 80.txt case via numeric prefix detection. Ours does too. For pure lexicographic sort (which would put 80.txt before 8.txt), pick the Lexicographic mode.

Common workflows

Sort a CSV before diffing. Sort both files, diff line-by-line; ordering noise vanishes.

Order an alphabetical glossary. Paste terms (one per line), sort, paste into your docs.

Reorder import statements. Many editors do this on save; for files outside the editor’s scope (legacy code, generated files), the tool stands in.

Group log lines. Sort first, then dedupe, surfaces clusters.

Frequently asked questions

Locale-aware?
Yes — pick a locale (en, de, fr, sv, etc.) and sorting follows that language's conventions (Swedish places ä after z; German treats it as ae).
Numerical sort?
8.txt sorts before 80.txt (and not after) — the comparator extracts numeric prefixes and compares as numbers, not strings.
How is sort stable?
Yes. Equal lines preserve input order. Same property as sort -s at the shell.
Strip empty lines?
Toggle. Default keeps empty lines; off-toggle removes them before sorting.
Performance?
Up to ~1,000,000 lines comfortably.
Diff-friendly?
Sorting + dedup before diffing two lists makes the comparison meaningful. Pair with Dedupe and Diff Checker.

Related tools

Last updated: 2025-01-15