Text ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Text Tools

Sort Lines Alphabetically Online

Sort lines A to Z or Z to A with natural ordering, so item2 comes before item10. Sort by the first number or by length, and drop blanks and duplicates.

View all tools
ResultUpdates as you type
2 kg
10 kg
Apple
apple
banana
cherry
item1
item2
item10
Zebra

10 lines sorted.

How to use Sort Lines Alphabetically Online

Paste one item per line and the sorted list appears as you type. Pick a sort method and order, and use the tick boxes to ignore case, trim spaces, remove blank lines or remove duplicates at the same time.

  1. Paste the linesPaste names, file names, keywords or prices, one per line.
  2. Choose method and orderNatural, character code, line length or first number in the line; ascending or descending.
  3. Tidy and copyRemove blank lines and duplicates if needed, check how many lines were sorted, then copy.

Natural sort versus character-code sort

Natural order compares numbers inside text by value, so you get item1, item2, item10, and 2 kg before 10 kg, as people expect. Character code order compares one character at a time, which puts 10 kg before 2 kg and item10 before item2; use it when you need strict code-point ordering, for instance to match a program's output. Natural order also sorts Chinese entries by pinyin. Ignore case (ticked by default) keeps Apple and apple together and, with Remove duplicate lines too, treats them as the same line so only the first one stays.

Sorting by number or by length

First number in the line sorts by the first number found in each line, so £45 phone, £950 car and £1,200 rent come out in value order; thousands separators, decimals and minus signs are understood. Lines with no number go to the end, and a note tells you how many there were. Line length sorts from the shortest line to the longest (or the reverse), which is handy for tidying import lists, CSS selectors or keyword lists; lines of equal length fall back to natural order.

Accuracy and data handling

Before copying the output, check names, punctuation and the intended meaning against the source text. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

How do I sort a list alphabetically?

Paste the list with one item per line and keep Sort by on Natural and Order on Ascending. The A to Z list appears immediately; choose Descending for Z to A.

Why does 10 come before 2 in my sorted list?

That is character-code sorting, which compares the digit 1 with 2. Choose Natural or First number in the line and numbers are compared by value instead.

Can it remove duplicates while sorting?

Yes. Tick Remove duplicate lines too. With Ignore case ticked, Apple and apple count as the same line and only the first is kept.

Can I sort Chinese text by pinyin?

Yes. Natural order uses a Chinese collation, so Chinese lines are sorted by pinyin, and chapter numbers inside them are compared by value.

More Text Tools

Related tools