DevKits

Sort Lines — Alphabetize, Natural Sort & Shuffle Text Online

Sort text lines alphabetically, numerically, by natural order (2 < 10), or by length. Also supports random shuffle, reverse, deduplicate on-the-fly, and case-insensitive comparison. 100% local.

Last updated:

44 chars · 8 lines
8 lines

Paste text with one item per line and pick a sort mode: alphabetical, natural (2 < 10), numeric only, by length, or random shuffle. Optional case-insensitive comparison, whitespace trimming, empty-line filtering, and inline deduplication.

What is Text Sort?

A text sorter reorders lines according to a chosen comparison. The two most common surprises: alphabetical sort puts '10' before '2' because it compares characters ('1' < '2'), and case-sensitive Unicode sort puts all uppercase letters before all lowercase ('Z' < 'a'). Natural sort fixes the first by treating numeric segments as numbers, so 'file2' correctly comes before 'file10'. Case-insensitive mode fixes the second. This tool exposes both plus a length-based sort (useful for finding the longest / shortest entries), a random shuffle (Fisher-Yates), and a one-click reverse.

How to sort text lines online

  1. 1Paste your list — one item per line.
  2. 2Pick a sort mode: Alphabetical, Natural, Numeric, Length, or Random.
  3. 3Toggle direction (A → Z or Z → A), case-sensitivity, and whether to trim / dedupe on the fly.
  4. 4The output pane updates instantly. Use the Reverse and Shuffle buttons for quick one-off reorderings.

Use Cases

Alphabetize a name list

Sort attendees, contact names, or any list into A→Z order for reports and directories.

Sort filenames in natural order

'file2.txt' should come before 'file10.txt'. Natural sort mode does exactly that, matching modern file managers.

Order log lines by numeric ID

Numeric mode extracts the leading number from each line for ordering — great for sorting timestamps or request IDs.

Randomize for A/B test bucketing

Shuffle a list of user IDs or feature flags to assign them to buckets without introducing order bias.

Tips & Best Practices

  • Enable 'Deduplicate' to combine sort + dedupe in one pass — equivalent to `sort -u` in bash.
  • Natural sort is what you almost always want for filenames, version strings, and mixed alphanumeric IDs.
  • Case-sensitive mode uses Unicode code-point order (matches Python / Go / RFC 8785 default), useful for canonical / deterministic ordering.
  • The shuffle uses Math.random — good enough for casual randomization, not for security-sensitive contexts like fair lotteries.

Frequently Asked Questions

What is 'Natural' sort?

Natural sort respects numeric segments inside strings, so 'file2' comes before 'file10' (not after). Standard alphabetical sort compares character-by-character and puts '10' before '2' because '1' < '2' by codepoint.

How does the tool handle mixed numbers and text?

In 'Numeric' mode, lines that parse as numbers are compared numerically; non-numeric lines are pushed to the end. In 'Natural' mode, both are handled inline (recommended for filenames, version strings, and IDs).

What does 'Case sensitive' do?

When on, uppercase letters sort before lowercase per Unicode code-point ordering ('Apple' < 'apple'). When off, letter case is ignored ('Apple' and 'apple' are equal for ordering).

Does the shuffle use a good random source?

Yes — Math.random powered Fisher-Yates shuffle, which produces a uniform permutation. For cryptographic-grade shuffling, use a dedicated tool with crypto.getRandomValues.

Is my text uploaded anywhere?

No. All sorting runs locally in your browser.

Related Tools