Skip to content
XUtilHub

Sort Text Lines Alphabetically

Sort lines A-Z, Z-A, by length, naturally (numbers aware) or randomly. Optionally remove duplicates. Free.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the Sort Lines

Sort lines alphabetically, by length, in natural order (so item2 comes before item10), or shuffle them randomly.

Key features

  • Sort A→Z or Z→A with locale-aware ordering
  • Natural sort: item2 comes before item10
  • Sort by line length, shortest or longest first
  • Reverse order or random shuffle
  • Optional case-insensitive sort and de-duplication
  • Remove empty lines while sorting

Sort lines of text instantly

Alphabetize a list of names, order file names numerically, shuffle quiz questions, or find the longest entries. Sort Text Lines handles every common ordering, with options to ignore case, remove duplicates and drop blank lines.

Sort modes

ModeInputOutput
A → Zbanana, Apple, cherryApple, banana, cherry
Z → Acherry, banana, Apple
Naturalitem10, item2, item1item1, item2, item10
Shortest firstkiwi, fig, bananafig, kiwi, banana
Longest firstbanana, kiwi, fig
Reverse ordera, b, cc, b, a
Randoma fair shuffle

Alphabetical vs. natural sorting

AlphabeticalNatural
img1.pngimg1.png
img10.pngimg2.png
img2.pngimg10.png

Natural sorting is what people expect for file names, versions, chapters and invoice numbers.

Use cases

  • Lists and glossaries in alphabetical order.
  • Bibliographies and references.
  • Keyword lists sorted and de-duplicated in one pass.
  • Random order for raffles, quiz questions, team picks or test data.
  • Code: sort import statements, CSS properties or enum values.

De-duplicate without sorting using Remove Duplicate Lines, sort words within a sentence with the Word Sorter, or reverse lines with Reverse Text.

How to use the Sort Lines

  1. Type or paste your text into the input box.
  2. Choose the options you want.
  3. The result updates instantly as you type.
  4. Copy the output or download it as a .txt file.

Frequently asked questions

What is natural sorting?

Natural sorting treats numbers inside text as numbers, so file2 comes before file10. Plain alphabetical sorting would put file10 first, because '1' sorts before '2'.

How random is the shuffle?

It uses the Fisher–Yates algorithm with the browser's cryptographically secure random numbers, so every order is equally likely.

Does it handle accented letters correctly?

Yes. Sorting uses Unicode collation, so é sorts next to e rather than after z.

Can I sort numbers?

Yes. Choose Natural so that 2, 10 and 100 sort numerically.

Is my text sent anywhere?

No. All text tools run locally in your browser.

Do these tools support Unicode?

Yes. They handle Unicode text, including emoji and accented characters.

Last updated:

Related Text tools