Sort Lines AlphabeticallyA–Z, by Number, or by Length

Paste a list with one item per line and sort it A–Z or Z–A, by the number in each line, or by length. You can also shuffle or reverse the lines and remove duplicates and blank lines.

Your input is never sent anywhere.

Details
DETECTED:0 ITEMS

Sort settings

Sort by
Order
Cleanup and matching

How lines are compared and ordered

The tool treats each line as one item. You choose what to sort by: the text itself (A → Z), the first number in the line, or the length of the line. Then you choose ascending or descending, or shuffle the lines, or reverse their order.

When you sort by text, numbers inside the lines can be compared by value, so item2 comes before item10. When you sort by number, the tool picks the first number in each line, so lines such as Widget $1,200.50 or No.5 sort by their price or number.

You can clean the list in the same step: trim spaces, remove blank lines, and remove duplicate lines. After you sort, a summary shows how many lines came in, how many came out, and what was removed.

Lists people sort most often

Word lists, names, and glossaries

Put a list of names, terms, or tags in A–Z order. Turn on Ignore case so capitalization does not split the list.

Prices, scores, and IDs

Sort lines by the number they contain, even when the number sits in the middle of the line with a name or a unit around it.

Keywords, URLs, and file names

Remove duplicates and sort in one step. With numbers sorted by value, file names such as img2 and img10 stay in the order you expect.

Random order and flipped lists

Shuffle a list to draw names or mix up test data. Reverse order flips a list, such as a log, without sorting it.

How to sort a list in 4 steps

  1. Paste your list into the Input box, with one item on each line.
  2. Under Sort by, choose Alphabetical, Number, or Length.
  3. Under Order, choose Ascending, Descending, Shuffle lines, or Reverse order.
  4. Set the cleanup options, click Sort lines, and copy the result.

Note: The result does not update on its own. Click Sort lines again after you change a setting. Remove duplicate lines is off by default.

How each setting behaves

  • One line, one item: the tool splits the text at line breaks. If a single item spans several lines, put it on one line first.
  • Number sorting: it uses the first number in each line, including decimals and negative numbers. Commas are removed first, and a hyphen after a letter or digit is not a minus sign. Lines with no number go to the end in their original order.
  • Sort by applies to Ascending and Descending: Shuffle and Reverse order ignore it.
  • Duplicates: an exact match after trimming. Apple and apple are different lines, and the first copy of each line is kept.
  • Length: counts characters in each line. Lines of equal length keep their original order.

Sort options at a glance

What each option does to your lines and when to use it.

OptionHow it orders the linesGood for
Alphabetical, ascendingA to Z. With Sort numbers in text by value on, item2 comes before item10.Names, terms, file names
Alphabetical, descendingZ to A. With Sort numbers in text by value on, item10 comes before item2.Reverse A–Z lists, highest-numbered names first
Number, ascendingBy the first number in each line, from small to large. Lines without a number come last.Prices, scores, IDs, quantities
Number, descendingBy the first number in each line, from large to small.Top sellers, highest counts
LengthBy the number of characters in each line, short to long or long to short.Comparing titles, headlines, and limits
Shuffle linesA random order, different each time you click.Drawing names, mixing test data
Reverse orderFlips the list from bottom to top without sorting it.Switching a log between oldest-first and newest-first
Remove duplicate linesKeeps one copy of lines that match exactly. Off by default.Cleaning keyword, URL, and email lists
Remove blank linesDrops empty lines. On by default.Tidying pasted lists

Why 1, 10, 2 happens
A plain sort compares text one character at a time, so 10 comes before 2 because 1 comes before 2. Sorting by Number reads each line as a value instead. For text that contains numbers, such as file names, turn on Sort numbers in text by value.

Your list stays in your browser
The tool runs as JavaScript on the page and has no upload step, so customer lists and other private data are not sent to a server.

Why numbers sort in the wrong order, and how to fix it

The three most common sorting surprises and the setting that solves each one.

Alphabetical order versus natural order

In a plain alphabetical sort, item10 lands before item2, because 1 comes before 2 and the sort never reads the whole number. Natural order compares runs of digits as numbers instead.
Turn on Sort numbers in text by value for names, file names, and version-like labels. Turn it off if you want a strict character-by-character order.

Sorting by a number inside the line

For a list such as Widget $1,200.50 or Room 12, choose Number so the sort reads the value. The tool takes the first number in each line, so a line such as Room 12 - 3 beds sorts by 12, not by 3.
Dates such as 2026-10-29 sort by the first number, which is the year. If another number should decide the order, move it to the front of the line first.

Clean the list before you sort

Spaces at the start of a line can change a sort, and blank lines clutter the result. Trim spaces around each line and Remove blank lines are on by default for that reason.
Duplicates are matched exactly, so Apple and apple stay as two lines. If you want them merged, change them to the same case before you paste the list.

Common problems when sorting lines

Numbers come out as 1, 10, 2, 20

The list is sorted as text, so each number is compared one character at a time and 10 lands before 2.

💡 See the solution▼
For lines that are numbers or contain a number you want to order by, choose Number under Sort by. For text that contains numbers, such as item2 and item10, turn on Sort numbers in text by value.

The wrong number decides the order

A line such as Room 12 - 3 beds has two numbers. Number sorting uses the first one, so the line sorts by 12.

💡 See the solution▼
Rewrite the lines so the number you want to sort by comes first, sort the list, and then change the lines back if you need to.

Lines disappear when you only wanted a sort

Removing duplicates can change the count of a list where repeated values matter, such as survey answers or log entries.

💡 See the solution▼
Remove duplicate lines is off by default. After you sort, the summary shows how many lines were removed, so you can see right away if the count is not what you expected.

One item spans several lines

An address or a message with line breaks inside it is split into separate lines, and the sort separates the parts.

💡 See the solution▼
Put each item on one line before you sort, for example by joining its lines with a comma. Keep a copy of the original list in case you need to go back.

Line sorter FAQ

Q.Can I sort lines by a number that is inside the line?

Q.

A. Yes. Choose Number under Sort by. The tool takes the first number in each line and sorts by it, so Widget 1,200.50 sorts as 1200.5 and No.5 sorts as 5. Commas are removed before the number is read, and decimals and negative numbers work. A hyphen right after a letter or digit is not a minus sign, so item-5 sorts as 5. Lines with no number keep their original order and are placed at the end.

Q.Why does a plain sort put item10 before item2?

Q.

A. A plain sort compares text one character at a time, and 1 comes before 2, so item10 lands before item2. In Alphabetical mode, turn on Sort numbers in text by value to compare runs of digits as numbers. Then item2 comes before item10, and the order becomes item1, item2, item3, item10, item20. Turn it off for a strict character-by-character order.

Q.How does Ignore case work?

Q.

A. With Ignore case when sorting A → Z on, Apple and apple are treated as the same word, and lines that differ only in case keep their original order. With it off, lines that differ only in case are ordered lowercase first, so a comes before A and both come before b. The setting does not affect Remove duplicate lines, which always treats Apple and apple as different lines.

Q.How does Remove duplicate lines work?

Q.

A. It is off by default, so no line is removed unless you turn it on. When it is on, lines that match exactly after trimming are reduced to one, and the first copy is kept. The duplicates are removed before the sort. After you sort, the summary above the result shows how many duplicate lines and blank lines were removed.

Q.What do Remove blank lines and Trim spaces do?

Q.

A. Remove blank lines drops empty lines. Trim spaces around each line removes spaces and tabs at the start and end of every line, and the result shows the trimmed lines. Trimming happens first, so a line that holds only spaces counts as blank when both options are on. Both options are on by default.

Q.Can I paste a column from Excel or Google Sheets?

Q.

A. Yes. A column you copy from a spreadsheet pastes with one value per line, so you can sort it here and paste the result back into the column. Sorting cannot keep other columns lined up with it, so use it for a single column. If cells hold more than one line of text, each line is sorted as its own item.

Q.What do Shuffle, Reverse order, and Length do?

Q.

A. Shuffle puts the lines in a random order using a Fisher-Yates shuffle, and a new order appears each time you click Sort lines. Reverse order flips the list from bottom to top without sorting it. Length sorts by the number of characters in each line, shortest first or longest first, and lines of equal length keep their original order. Emoji and some rare characters count as two characters.

Q.Is there a limit on how many lines I can sort?

Q.

A. The tool sets no line limit. It runs in your browser and uses your device's memory, so a very large list can take longer on an older device. If the page slows down, sort the list in smaller parts.

Q.Is my list sent to a server?

Q.

A. No. The tool sorts your text with JavaScript in your browser, and the page has no upload step. Your text is held only in the page while it is open, and closing or reloading the page clears it.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback