🔤 Sort Text Lines (Alphabetical)
By ToolNimba Editorial Team · Updated 2026-06-19
Paste a list above to sort the lines.
This tool sorts a list of text lines into the order you want. Paste your lines in the box, choose a method (alphabetical A to Z, Z to A, by length, numeric, or reverse), and the sorted result appears instantly. You can also trim stray spaces and remove duplicate lines in the same pass, then copy the clean list with one click. Everything runs in your browser, so your text is never uploaded anywhere.
What is the Sort Text Lines?
Sorting lines means rearranging the rows of text without changing the text itself. Each line break (Enter) marks the boundary between items, so a list of names, URLs, words, or numbers, one per line, becomes a set of items the tool can reorder. The most common goal is alphabetical order, where lines are compared character by character until they differ. "Apple" comes before "Banana" because A is earlier than B, and "Apple" comes before "Apples" because the shorter string runs out first.
Alphabetical sorting is not always the order people expect, mainly because of case and numbers. By default many sorts treat uppercase letters as coming before lowercase ones, so "Zebra" can land before "apple". This tool offers an "ignore case" option so "Apple" and "apple" are treated as equal for ordering. Numbers are trickier: as plain text, "10" sorts before "2" because the character "1" comes before "2". When your lines are really numbers, use the numeric method, which reads the value of each line so 2 comes before 10 as you would expect.
Beyond A to Z and Z to A, two other orders are often useful. Sorting by length lines up your shortest entries first (handy for spotting blank or truncated rows), and reversing simply flips whatever order the list is currently in. Combined with trimming and de-duplication, these options turn a messy paste from a spreadsheet, log file, or email into a tidy, ordered, unique list ready to use elsewhere.
When to use it
- Alphabetizing a list of names, book titles, or product SKUs before pasting it into a document.
- Cleaning up a column copied from a spreadsheet by trimming spaces and removing duplicate rows.
- Ordering a list of numeric IDs or prices from smallest to largest with the numeric sort.
- Sorting keywords or tags into alphabetical order for an index, glossary, or content brief.
How to use the Sort Text Lines
- Paste or type your text into the input box, one item per line.
- Choose a sort method: A to Z, Z to A, by length, numeric, or reverse the current order.
- Tick "ignore case" if "Apple" and "apple" should be treated as equal, and "trim spaces" to clean each line.
- Tick "remove duplicate lines" if you also want to drop repeats.
- Read the sorted result and press Copy to put it on your clipboard.
Formula & method
Worked examples
Sort the list banana, Apple, cherry, apple into A to Z order with "ignore case" on and duplicates removed.
- Trim and read the four lines: banana, Apple, cherry, apple.
- With ignore case on, "Apple" and "apple" count as the same item, so one duplicate is removed, leaving banana, Apple, cherry.
- Compare ignoring case: apple (a), banana (b), cherry (c).
- Order the remaining lines: Apple, banana, cherry.
Result: Apple, banana, cherry (3 lines out, 1 duplicate removed)
Sort the lines 2, 10, 1, 21 smallest first.
- As plain text, alphabetical order would give 1, 10, 2, 21, which is wrong for numbers.
- Switch to "Numeric, smallest first" so each line is read as a value.
- Compare the values: 1 < 2 < 10 < 21.
Result: 1, 2, 10, 21
Sort methods and what each one does
| Method | What it does | Example order |
|---|---|---|
| Alphabetical A to Z | Orders lines from earliest to latest letter | apple, banana, cherry |
| Alphabetical Z to A | Orders lines from latest to earliest letter | cherry, banana, apple |
| By length (shortest first) | Orders by number of characters per line | hi, cat, hello |
| By length (longest first) | Longest lines come first | hello, cat, hi |
| Numeric (smallest first) | Reads the number in each line and sorts by value | 1, 2, 10, 21 |
| Reverse current order | Flips the list as it currently stands | last line becomes first |
Why text sort and numeric sort differ
| Lines | Text (A to Z) | Numeric (smallest first) |
|---|---|---|
| 2, 10, 1 | 1, 10, 2 | 1, 2, 10 |
| 9, 100, 30 | 100, 30, 9 | 9, 30, 100 |
Common mistakes to avoid
- Expecting numbers to sort by value in alphabetical mode. In alphabetical order "10" comes before "2" because it is compared as text, character by character. When your lines are numbers, switch to a numeric sort so values are compared instead.
- Forgetting that case affects the order. By default uppercase letters can sort before lowercase ones, so "Zebra" may appear above "apple". Turn on "ignore case" if you want a normal dictionary-style order regardless of capitalisation.
- Leaving trailing spaces in the lines. A line that ends in a space, or that has a leading space, can sort differently from one that looks identical on screen. Keep "trim spaces" on so invisible whitespace does not change the order or hide duplicates.
- Treating wrapped text as separate lines. This tool splits on actual line breaks, not on visual wrapping. If a long paragraph wraps across the box it is still one line, so press Enter where you genuinely want a new item.
Glossary
- Line
- A single row of text, ending where you press Enter. The tool treats each line as one item to be sorted.
- Alphabetical order
- Arranging items by their letters, comparing character by character so words starting with A come before those starting with B.
- Case-insensitive
- A comparison that treats uppercase and lowercase versions of a letter as equal, so "Apple" and "apple" sort together.
- Numeric sort
- Ordering lines by the numeric value they contain rather than by their text, so 2 comes before 10.
- Duplicate
- A line whose text is identical to another line already in the list. Removing duplicates keeps only the first occurrence.
Frequently asked questions
How do I sort a list alphabetically?
Paste your list into the box with one item per line, then choose "Alphabetical, A to Z". The sorted list appears instantly and you can copy it. Turn on "ignore case" for a standard dictionary order.
Why does 10 come before 2 when I sort?
Alphabetical sorting compares text character by character, and the character "1" comes before "2", so "10" lands before "2". To sort by value instead, pick the "Numeric, smallest first" or "Numeric, largest first" method.
Can I sort lines from Z to A?
Yes. Choose "Alphabetical, Z to A" to reverse the alphabetical order so lines starting with later letters come first. There is also a plain "Reverse current order" option that flips the list as it stands.
Does this tool remove duplicate lines too?
Yes. Tick "remove duplicate lines" and any repeated line is dropped, keeping the first occurrence. With "ignore case" on, lines that differ only in capitalisation count as duplicates.
Is my text uploaded anywhere?
No. All sorting happens in your browser with JavaScript, and nothing is sent to a server. You can even use the tool offline once the page has loaded.
What does sorting by length do?
Sorting by length orders lines by how many characters they contain rather than by their letters. Shortest-first is handy for spotting blank or truncated rows, while longest-first surfaces your fullest entries.