AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I sort lines of text online?

Paste your list into AnyTool Sort Lines and pick a method. It sorts alphabetically (A to Z or Z to A), with a natural order so file2 comes before file10, numerically, by line length, by the last word, or by a delimited column — and can reverse or shuffle. Toggle ignore case, trim whitespace, remove duplicates and handle blank lines. Everything runs in your browser, so your text is never uploaded.

  • Alphabetical A to Z and Z to A, with locale-aware collation
  • Natural / numeric sort so file2 sorts before file10
  • Sort by line length, by the last word, or by a delimited column
  • Reverse or shuffle lines, ignore case, trim, remove duplicates
  • 100% in your browser — no upload, no signup, works offline

What is

Sort Lines

Sorting lines reorders the lines of a block of text by a comparison rule — alphabetical, natural (numeric-aware), numeric, by length, by a column or by the last word — in ascending or descending order. Natural sort treats embedded numbers as values, so item2 precedes item10, unlike a plain alphabetical sort.

Text Tools

Related terms

AlphabetizeNatural SortSort by LengthLocale Collation

Frequently Asked Questions

No upload happens. All sorting runs in your browser, so your text never leaves your device and the tool works offline.

Every sort is computed locally in your browser with JavaScript. Nothing is sent to a server, there is no tracking, and the page works offline after the first load — so you can safely sort confidential name lists, email lists, logs or code.

Natural sort reads the numbers inside each line as values, so file2 sorts before file10 instead of after it.

A plain alphabetical sort compares text character by character, so "file10" comes before "file2" because the character "1" is less than "2". Natural sort, implemented with Intl.Collator using numeric collation, treats runs of digits as whole numbers, so file1, file2, file10 line up the way people expect.

Yes. Choose the "by column" method, set the delimiter (comma, tab, semicolon or custom) and a 1-based column number.

The column sort splits each line on a delimiter you choose — comma, tab, semicolon, pipe, space or any custom string — and sorts by the value in the column index you specify (1-based). It is ideal for ordering CSV or TSV rows by a particular field without opening a spreadsheet.

Yes. Turn on locale-aware sorting and pick a locale so accented and non-English letters order correctly.

Locale-aware sorting uses Intl.Collator with the locale you choose, so diacritics and language-specific rules are respected — for example Swedish places å, ä and ö after z, and German handles umlauts correctly. You can also ignore case so capitalisation does not split related words.

Detailed Explanation

Methodology

How the Sort Lines Tool Works

AnyTool Sort Lines splits the input on newlines (handling both LF and CRLF) and reorders the lines entirely in the browser. Alphabetical and natural sorting use Intl.Collator — natural mode enables numeric collation so embedded numbers compare as values (file2 before file10). Numeric mode sorts by the first signed number parsed from each line, length mode by character count, and column mode by a delimited field. A stable, index-based sort preserves the original order of equal lines.

  • Lines split on LF or CRLF; the original newline style is preserved on output
  • Alphabetical and natural sort use Intl.Collator with optional locale and case folding
  • Natural sort uses numeric collation so file2 sorts before file10
  • Numeric sort reads the first signed number in each line; non-numbers sort last
  • Column sort splits on a chosen delimiter and sorts by a 1-based index
  • The sort is stable — equal lines keep their original relative order
How It Works

Normalisation, Locale and Blank Handling

Before comparing, each line can be trimmed or have its leading whitespace ignored, and case can be folded so capitalisation does not separate related entries. Locale-aware collation respects diacritics and language-specific ordering, such as Swedish placing å, ä and ö after z. Duplicates can be removed after sorting, and blank lines can be kept, removed, or pushed to the end. Reverse simply flips the current order, while shuffle uses a seedable Mulberry32 PRNG so a given seed reproduces the same random order.

  • Trim or ignore leading whitespace and ignore case before comparing
  • Locale-aware collation handles accents and language-specific letter order
  • Remove duplicates after sorting, keeping the first occurrence
  • Blank lines: keep, remove, or move to the end
  • Reverse and a reproducible seeded shuffle are first-class options
Privacy & Security

Privacy and Offline Use

Because all sorting runs in the browser, the text never reaches a server, there is no account or tracking, and the page works offline after first load. Live stats report lines in and out, duplicates and blanks removed, and whether the order actually changed. Large inputs are debounced so the editor stays responsive, and results can be copied or downloaded as a .txt file.

Line sorting: in-browser (AnyTool) vs typical online sort tools
CapabilityAnyToolTypical online sort tools
Text handlingProcessed in your browserOften posted to a server
PrivacyText never leaves deviceMay log or store submitted text
Natural sortYes (file2 before file10)Frequently missing
Locale-aware collationYes, with locale pickerRarely offered
Sort by columnYes, delimiter + 1-based indexUncommon
Shuffle / reverseBoth, shuffle is reproducibleSometimes separate tools
Works offlineYes (PWA)No
Cost / signupFree, no signupOften ad-heavy or gated

Server-based sort tools can retain pasted text in logs; AnyTool reorders every line locally and uploads nothing.