📋

Sort Lines

A line sorter reorders each line of pasted text by a rule you choose. Paste your list, pick Alphabetical, Numeric, By Length, Natural, Random or Reverse, and the result box updates as you type. Natural order is the one people expect from filenames: file10, file2, file1 comes back as file1, file2, file10, where plain alphabetical gives file1, file10, file2.

Text workspace

Order a line list using alphabetic, numeric, length, natural, random or reverse mode.

Method and limits

Natural compares digit runs numerically: file2 precedes file10. Numeric accepts only whole finite decimal or scientific-notation lines; invalid or blank lines stay at the end in their original order, even when descending. Length counts graphemes; reverse flips input order.

Case sensitivity affects matching and alphabetic/natural comparison. Remove blanks and duplicates are optional. Random is a browser shuffle for ordinary lists, not a security or fairness guarantee. Line contents are retained. Whole-grapheme processing needs Intl.Segmenter. If your browser lacks it, only ASCII text is processed; Unicode input stays unchanged in the editor with an error. Use a browser with segmentation support.

Try this example

file10, file2, file1 → file1, file2, file10 in Natural. Numeric: 2, nope, 10 → 2, 10, nope.

Input Lines
Output Lines
Removed
Advertisement

Copied

Copy failed. Select the result and copy it manually.

Embed this tool on your website

Use whole pixel dimensions from 1 to 4096.

× px (1–4096)

                        

💡 Integration Tip

Copy the embed code and paste it into your website HTML. The responsive version adapts to all screen sizes automatically.

2.8
4 ratings
✓

Popular Tools

No more tools to show
Explore All Tools

About Sort Lines

Order a line list using alphabetic, numeric, length, natural, random or reverse mode. Natural compares digit runs numerically: file2 precedes file10. Numeric accepts only whole finite decimal or scientific-notation lines; invalid or blank lines stay at the end in their original order, even when descending. Length counts graphemes; reverse flips input order.

file10, file2, file1 → file1, file2, file10 in Natural. Numeric: 2, nope, 10 → 2, 10, nope.

These transformations run in your browser. The page still has its existing ads, consent and analytics requests; handwriting also loads Google Fonts. Copy or export useful results before closing.

Use Cases

A developer pastes a list of imports from the top of a file, sorts alphabetically, and pastes the block back so the diff in the pull request shows one ordering change instead of a scatter of moved lines.
A marketer cleaning a keyword export ticks Remove duplicates and Remove blanks, reads the Removed counter to see how many rows the export actually wasted, and copies the survivors into the planner.
A sysadmin ordering a list of exported filenames uses Natural rather than Alphabetical so backup-2 lands before backup-10 instead of after it.
A teacher preparing a spelling test pastes the week's words and presses Shuffle, then repeats it for a second group so the two classes get the same words in a different order.
A copywriter trimming a list of feature bullets sorts By Length to find the three longest lines, which are usually the ones that need rewriting before the page ships.

How to use

1

Order a line list using alphabetic, numeric, length, natural, random or reverse mode.

2

Natural compares digit runs numerically: file2 precedes file10. Numeric accepts only whole finite decimal or scientific-notation lines; invalid or blank lines stay at the end in their original order, even when descending. Length counts graphemes; reverse flips input order.

Pro Tips

  • Case sensitivity affects matching and alphabetic/natural comparison. Remove blanks and duplicates are optional. Random is a browser shuffle for ordinary lists, not a security or fairness guarantee. Line contents are retained. Whole-grapheme processing needs Intl.Segmenter. If your browser lacks it, only ASCII text is processed; Unicode input stays unchanged in the editor with an error. Use a browser with segmentation support.

Troubleshooting

Problem:

The first line of the result is empty.

Solution:

Your list contains a blank line, and in alphabetical order an empty string sorts before every word. The shipped sample does exactly this. Tick Remove blanks to drop lines that hold only whitespace; the Removed counter will confirm how many were taken out.

Problem:

Numeric sorting put words at the top of the list.

Solution:

Numeric mode reads each line as a number and any line that does not start with one is treated as zero, so text lines gather at the bottom of the negative range - before every positive number. Sorting 10, apple, 2, banana returns apple, banana, 2, 10. Separate the numbers from the text, or use Alphabetical or Natural instead.

Problem:

Remove duplicates deleted lines that differ in capitalisation.

Solution:

Duplicate matching is case-insensitive until you tick Case sensitive. Apple, apple and APPLE are one line by default and the counter shows two removed. Tick Case sensitive and all three are kept. This is the checkbox to reach for when the capitalisation carries meaning, such as environment variable names.

Problem:

Descending does nothing.

Solution:

You are in Random or Reverse mode, where the option is ignored on purpose because neither has an ascending direction to flip. Switch to Alphabetical, Numeric, By Length or Natural and Descending takes effect immediately; to invert a shuffled list, run Reverse afterwards.

Problem:

Input lines says 1 when the box looks empty.

Solution:

An empty box still splits into one line, so the counter reads Input lines 1, Output lines 1 and Removed 0. That is arithmetic, not a fault. The same effect shows at the other end: a list ending with a newline counts one more line than you can see, because the text after the last break is an empty line.

Frequently Asked Questions

Natural compares digit runs numerically: file2 precedes file10. Numeric accepts only whole finite decimal or scientific-notation lines; invalid or blank lines stay at the end in their original order, even when descending. Length counts graphemes; reverse flips input order. file10, file2, file1 → file1, file2, file10 in Natural. Numeric: 2, nope, 10 → 2, 10, nope.

Case sensitivity affects matching and alphabetic/natural comparison. Remove blanks and duplicates are optional. Random is a browser shuffle for ordinary lists, not a security or fairness guarantee. Line contents are retained. Whole-grapheme processing needs Intl.Segmenter. If your browser lacks it, only ASCII text is processed; Unicode input stays unchanged in the editor with an error. Use a browser with segmentation support.

Paste the lines into the input box and leave the Alphabetical button selected - it is the default, and the result box fills in as you type. Tick Descending for Z to A. The comparison uses the browser locale rules rather than raw character codes, which is why apple sorts before Banana instead of after it.

Natural sorting reads runs of digits as numbers. Given file10, file2 and file1, Natural returns file1, file2, file10, while Alphabetical returns file1, file10, file2 because it compares "1" against "2" one character at a time. Use Natural for anything with a counter in the name: filenames, version strings, invoice numbers.

Tick Remove duplicates. The first occurrence of each line is kept and later repeats are dropped, and the Removed counter shows how many went. Matching ignores case unless you also tick Case sensitive: Apple, apple and APPLE collapse into one line by default, and stay as three lines when Case sensitive is on.

Yes - press By Length and lines are ordered by character count, shortest first, with Descending flipping that. The count includes spaces and punctuation, so "New York" is eight characters. On a list of aaa, a, aaaa, aa the tool returns a, aa, aaa, aaaa.

By default yes, and in Alphabetical order a blank line sorts to the top because an empty string compares before every word. The sample list this page opens with has one blank line, which is why the first result row looks empty. Tick Remove blanks to drop every line that holds only whitespace, and the Removed counter tells you how many went.

FreeWebTools AI