Sort Text Lines

Sort any list of text lines alphabetically, in reverse, or numerically, with case and duplicate options. Paste, sort, copy. No signup. Ideal for lists, data cleanup and CSV prep.

Remove Ads
Remove Ads

Result

Sorted Lines
Remove Ads

Share on Social Media:

This tool sorts lines of text alphabetically, in reverse order, or numerically, directly in your browser. Paste your list, choose the sort type and options such as case sensitivity, and copy the ordered result. No account, no app, and no install, so you can tidy any list of names, items or data on any device in seconds.

How to Sort Text Lines Step by Step

  1. Paste your lines. Drop your list into the input box, one item per line. It can be names, filenames, numbers, tasks, or any text where each line is a separate entry to be ordered.
  2. Choose the sort direction. Select ascending for A to Z or smallest to largest, or descending for Z to A or largest to smallest, depending on how you want the list ordered.
  3. Pick alphabetical or numeric. Use alphabetical for words and mixed text. Switch to numeric when your lines are numbers, so that ten sorts after nine rather than between one and two.
  4. Set case and duplicate options. Decide whether uppercase and lowercase should be treated the same, and whether to remove duplicate lines as part of the sort for a clean, deduplicated list.
  5. Copy the sorted result. The ordered lines appear in the output. Copy them back into your document, spreadsheet or code with a single click, ready to use.
Text line sorter arranging a list alphabetically

How Text Sorting Works and Why Order Rules Matter

Sorting text seems trivial until you meet the rules that govern it. The default is lexicographic order, which compares strings character by character using each character underlying code value. Because uppercase letters have lower code values than lowercase in the standard ASCII and Unicode ordering, a naive sort places all capitalised words before any lowercase ones, so Zebra can sort before apple. This surprises people who expect a human dictionary order, and it is why a case insensitivity option exists.

The gap between alphabetical and numeric sorting causes the most confusion. Sorted as text, the numbers one, two and ten order as one, ten, two, because the character one comes before the character two and lexicographic comparison looks at the first character first. Sorted numerically, they correctly order one, two, ten. This is not a bug, it is the difference between comparing strings and comparing values, and choosing the right mode is essential when your lines are numbers.

Alphabetical and numeric are different. Sorted as text, numbers order as 1, 10, 2, 3 because it compares character by character. Sorted numerically, they order as 1, 2, 3, 10 by value. If your lines are numbers, choose numeric mode, or you will get an ordering that looks broken but is technically correct for text.

Natural sort order is a refinement that tries to match human expectations for mixed text and numbers, so that file2 comes before file10 rather than after it. Pure lexicographic sorting places file10 before file2 because the character one precedes the character two. Natural sorting detects the numeric portions and compares them as values, which is why operating systems adopted it for file listings. It matters whenever your lines mix words and numbers, such as versioned filenames.

Deduplication frequently accompanies sorting because the two operations solve related problems. Sorting groups identical lines together, which makes duplicates adjacent and therefore easy to remove in a single pass. Combining sort and deduplicate produces a clean, ordered, unique list, which is exactly what is needed when merging several lists, tidying a set of tags, or preparing a column of values for import into a database or spreadsheet without repeats.

Online Sorter Versus Spreadsheet or Command Line

MethodStrengthsWeaknessesBest for
This online toolInstant, no install, case and numeric options, deduplicate built inHandles one list at a time, not linked to a data sourceQuick one off sorting of any pasted list
Spreadsheet sortSorts alongside related columns, part of a larger workflowSlower to set up for a single column, overkill for a plain listData that lives in rows with multiple fields
Command line sortScriptable, handles huge files, automatableRequires terminal knowledge, syntax for numeric and case optionsDevelopers processing large files in a pipeline
Manual reorderingNo tools needed for a tiny listError prone and painfully slow beyond a handful of linesThree or four lines you can eyeball

Who Needs to Sort Lines of Text

Writers and editorsAn editor sorts a glossary, index or reference list alphabetically so it is easy to scan and check for gaps, without manually reshuffling entries.
Developers and data workersA developer sorts a list of keys, tags or filenames, often with deduplication, to produce a clean canonical set for code or configuration.
Marketers managing keywordsA marketer alphabetises or numerically orders a keyword or URL list to spot patterns, group related terms, and remove accidental repeats before analysis.
Teachers and administratorsAn administrator sorts a class roster or attendee list into alphabetical order for a register or seating plan, straight from a pasted list.
Anyone tidying a listA person with a jumbled list of items, tasks or names sorts it into a sensible order in seconds rather than dragging lines around by hand.
Data worker sorting and deduplicating a list of values

Pro Tips for Clean, Correct Sorting

Switch to numeric mode for numbers. If your list is numbers and the order looks wrong, you are almost certainly sorting as text. Change to numeric mode so values order by size rather than by leading character.
Turn on case insensitivity for names. For human readable lists such as names and words, enable case insensitive sorting so Apple and apple sit together, matching the dictionary order people expect.
Deduplicate while you sort. When merging lists, enable duplicate removal during the sort to get a clean, unique, ordered result in one step rather than sorting and then hunting for repeats.
Trim whitespace first if results look off. Leading or trailing spaces affect sort order and can push a line to an unexpected place. If sorting seems wrong, run the list through our Whitespace Remover first.
Remove blank lines to avoid gaps. Empty lines sort to the top or bottom and clutter the result. Clean them out beforehand, or use our Remove Duplicate Lines and related text tools to tidy the input.
Reverse sort to find extremes fast. A descending sort brings the largest numbers or last alphabetical entries to the top, which is a quick way to find maximum values or check the end of a range without scrolling.

Common Text Sorting Mistakes to Avoid

Sorting numbers as text. Leaving the tool in alphabetical mode for a list of numbers produces the order 1, 10, 2, which looks broken. It is correct for text but not for values. Switch to numeric mode whenever your lines are numbers.
Ignoring case sensitivity. A case sensitive sort separates capitalised and lowercase versions of the same word, scattering names that should sit together. For human lists, enable case insensitivity so the order matches dictionary expectations.
Overlooking hidden whitespace. Trailing spaces and tabs change how a line compares and can push it to a surprising position. If a line sorts to the wrong place, invisible whitespace is the usual culprit, so clean the input first.
Leaving blank lines in the list. Empty lines get sorted like any other line and end up bunched at one end, creating gaps in your result. Remove blank lines before sorting for a clean, gap free output.

To clean a list before sorting, our Remove Duplicate Lines and Whitespace Remover tidy the input. After sorting, the Line Counter confirms how many entries you have, and the Reverse List flips the order without a full re sort.

Sorted list of text lines ready to copy

Frequently Asked Questions

How do I sort a list of text lines alphabetically?

Paste your list into the input box with one item per line, choose alphabetical mode and ascending direction for A to Z, then copy the sorted output. For human readable lists, enable the case insensitive option so capitalised and lowercase words sort together as they would in a dictionary, rather than all capitals appearing before all lowercase words.

Why do my numbers sort in the wrong order?

You are most likely sorting them as text rather than as numbers. In text mode the tool compares character by character, so ten sorts before two because the character one precedes the character two. Switch to numeric mode and the tool compares actual values, ordering one, two, three, ten correctly. This is the single most common sorting mistake.

Can I remove duplicate lines while sorting?

Yes. Enable the deduplicate option and the tool removes repeated lines as part of the sort, producing a clean, ordered, unique list in one step. This is especially useful when merging several lists together, since sorting groups identical lines adjacently and the deduplicate pass then strips the repeats, leaving one of each in order.

Does the sorter treat uppercase and lowercase differently?

By default, standard sorting places uppercase letters before lowercase because of their character codes, so Zebra can appear before apple. Turn on the case insensitive option to treat both the same, which gives the dictionary style order most people expect for names and words. Choose case sensitive only when the distinction genuinely matters for your data.

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

There is no fixed limit for typical use, and the tool comfortably handles lists from a few lines to many thousands directly in your browser. Extremely large files are better suited to a command line sort, but for the everyday lists people paste, names, keywords, tags, filenames, the online sorter processes them instantly at no cost.

What is natural sort order?

Natural sort order compares the numeric parts of mixed text as values rather than characters, so file2 comes before file10, matching human expectations. Pure lexicographic sorting would place file10 before file2 because the character one precedes two. Natural sorting is what operating systems use for file listings and is helpful whenever your lines mix words with numbers, such as versioned names.

Is the text line sorter free to use?

Yes, it is completely free with no account and no usage limit. You can sort as many lists as you like, as often as you like, with full access to the alphabetical, numeric, case and deduplicate options. It runs entirely in your browser on any device, so there is nothing to download, install or pay for.

How do I fix a line that sorts to an unexpected place?

The usual cause is hidden whitespace, a leading or trailing space or tab that changes how the line compares. Clean the list with a whitespace remover first, then sort again. Also check whether the line contains a different character than it appears to, such as a look alike symbol, which can also affect its sorted position.