Skip to content

Sort Lines Online - Alphabetical, Numeric, Natural

Sorted (0 lines)

Sort a List of Lines

Paste any list with one item per line and pick a sort order. The sorted result appears straight away, with a line count, a copy button and a .txt download. Remove blank lines and Trim whitespace are on by default, because pasted lists often carry empty lines and stray spaces that would otherwise sort to the top.

Sort Orders Explained

  • A–Z and Z–A sort alphabetically using your browser's language rules, so case and accents do not split the list into groups.
  • Natural treats numbers inside text as numbers. It is the order a person expects for file names like photo1, photo2, photo10.
  • Numeric sorts by the first number on each line, which suits prices, scores, sizes and line items like "250 g flour".
  • By length puts the shortest lines first. Lines of equal length keep their original order.
  • Reverse order flips the list upside down without sorting it, which is handy for log files where the newest entry is at the bottom.
  • Shuffle puts the lines in a random order.

Worked Example

Take this list of file names:

report10.pdf
report2.pdf
Report1.pdf
report2.pdf

notes.txt

A–Z gives notes.txt, Report1.pdf, report10.pdf, report2.pdf, report2.pdf. The blank line is gone and Report1 sits with the other reports despite the capital R, but report10 still comes before report2.

Natural gives notes.txt, Report1.pdf, report2.pdf, report2.pdf, report10.pdf, which is the order most people want.

Natural with Remove duplicates on gives notes.txt, Report1.pdf, report2.pdf, report10.pdf.

Numeric gives Report1.pdf, report2.pdf, report2.pdf, report10.pdf, notes.txt. notes.txt has no number, so it goes last.

Common Uses

Sorted lists are easier to scan and to compare. Sorting .gitignore entries, dependency lists or environment variable names keeps diffs small, because new entries land in a predictable place. Shuffle is handy for picking a presentation order or a random sample. On the command line, sort does A–Z (byte order unless your locale says otherwise), sort -V is close to Natural, sort -n to Numeric, and shuf shuffles.

Tips

If your items are separated by commas rather than line breaks, use the List Deduplicator with Split on set to Comma, which can also sort. To see what changed between two versions of a list, use List Diff. To wrap each sorted line in quotes or add a trailing comma, pass the result through Add Prefix and Suffix. Everything runs locally in your browser, so nothing you paste is sent to a server.

Related Tools

Frequently Asked Questions

What is the difference between A–Z and natural sort?
A–Z compares text character by character, so file10 comes before file2 because the character 1 is lower than 2. Natural sort reads runs of digits as numbers, so file2 comes before file10. Use natural sort for file names, version numbers and anything with numbers inside text.
How does numeric sort handle lines that are not just numbers?
Each line is sorted by the first number found in it, so '12 apples' sorts as 12. Thousands separators are ignored, so 1,000 sorts as one thousand. Negative numbers and decimals work. A hyphen only counts as a minus sign when it starts the number, so SKU-3 still sorts before SKU-20. Lines with no number at all go to the end in their original order.
Is the A–Z sort case-sensitive?
No. Sorting uses your browser's locale rules, which put apple, Banana and cherry in dictionary order rather than putting all capital letters first. Accented letters sort next to their plain versions, so é sorts with e.
How does Remove duplicates decide two lines are the same?
Lines must match exactly, including case. With Trim whitespace on, leading and trailing spaces are removed first, so 'apple' and 'apple ' count as the same line. For case-insensitive de-duplication and a report of which lines repeated, use the List Deduplicator.
Is the shuffle random?
Shuffle uses the Fisher–Yates algorithm with the browser's Math.random, which gives every order an equal chance. It is fine for picking a random order for a quiz or a raffle draw, but it is not a cryptographic random source. Click Shuffle again for a new order.