Sort Lines Alphabetically

Agarapu Ramesh — Editor and content reviewer

What This Tool Does

This tool sorts lines of text using one of several methods: alphabetical (A–Z or Z–A), numeric (for lists of numbers), by line length, or reverse the original order. Options include case-sensitive sorting, removing duplicates, and locale-aware comparison for accented characters.

Inputs Explained

How It Works

The text is split by newlines into an array. The chosen sort method is applied using JavaScript's Array.sort with a custom comparator. Alphabetical uses localeCompare for proper handling of accents and Unicode. Numeric sort parses each line as a number. Length sort compares string lengths.

Formula / Logic Used

A-Z: a.localeCompare(b) Numeric: parseFloat(a) - parseFloat(b) Length: a.length - b.length Reverse: array.reverse()

Sort any list of lines alphabetically, numerically, by length, or reverse order.

Step-by-Step Example

Input:

banana
Apple
cherry
10
2
apple

Method: Alphabetical A-Z (case insensitive)

Output:

10
2
Apple
apple
banana
cherry

For numeric sort: 2, 10, Apple, apple, banana, cherry (numbers first in ascending order, text alphabetically after).

Use Cases

Assumptions and Limitations

Disclaimer: All sorting happens in your browser. Your text is never uploaded or logged.

Frequently Asked Questions

How to sort lines alphabetically online

Paste your list with one item per line, click Sort A-Z, and the tool reorders everything alphabetically. Copy the result. Works on names, URLs, titles, anything where each line is a separate item. By default sorting is case-sensitive, so capital letters come before lowercase ones. Switch on the case-insensitive toggle if "Apple" and "apple" should sort together. For a Z-to-A sort, there's a separate descending option right next to the ascending button.

How to alphabetize a list online

Same idea as sorting lines alphabetically. Paste your list with each item on its own line, click Sort A-Z. The tool returns the list in alphabetical order. Numbers, when mixed with words, sort by their character value rather than their numeric value — so "10" comes before "2" in default mode. Switch to numeric sort if your list is numbers. Switch to case-insensitive if mixed capitalisation is causing weird sort order. Copy and paste the cleaned output.

How to sort numbers in a text list

Pick the Numeric Sort option instead of alphabetical. The tool then reads each line as a number and orders them by value — "2" before "10", "100" after "20". Without numeric mode, sorting goes character-by-character, which puts "10" before "2" because "1" comes before "2". Useful for sorting price lists, ID numbers, dates in YYYY-MM-DD format, or any column of numbers you've copied out of a spreadsheet that needs reordering.

How to sort lines by length online

Switch the sort mode to "by length". The tool then orders lines from shortest to longest, counting characters per line. So a list of "cat, elephant, dog, ant, hippopotamus" becomes "ant, cat, dog, elephant, hippopotamus" when sorted shortest-to-longest. Use Reverse Order to flip it longest-to-shortest. Useful for finding outlier-length entries in a dataset, organising poetry, or just quick visual sorting when alphabetical doesn't help much. A small but oddly useful feature.

How to randomize lines in a list

Switch to the Shuffle or Random Order mode. The tool returns your lines in a random sequence — every click gives a different order. Useful for randomising playlist order, shuffling quiz questions, picking a random winner from a list of names, or breaking up a sorted list when you don't want any pattern. The randomisation is fresh each time, so don't worry about hidden patterns; click again if you want a different result.

How to sort text in reverse alphabetical order

Click Sort Z-A (or "descending"). The tool orders your lines from Z down to A — exactly the opposite of normal alphabetical sort. So "apple, banana, mango" becomes "mango, banana, apple". Useful for finding entries that start with later letters, organising countdown lists, or reversing a sort you just did. Combine with case-insensitive mode if mixed capitalisation is throwing off the order. Numeric values can also be sorted high-to-low using descending numeric mode.

How to sort a list and remove duplicates online

Two-step on the same page. First, run Sort A-Z to alphabetise your list. Then, if there's a "remove duplicates" toggle, switch it on before sorting; if not, copy the sorted output, paste it into the dedupe tool, and run Remove Duplicates. The result is a clean, alphabetised, unique list. Useful for cleaning email lists, contact files, URL collections, or anything that combines messiness with repetition. Three clicks, no spreadsheet needed.

Sources and References

Related Calculators

Remove Duplicate LinesFind & ReplaceReverse TextWhitespace RemoverCase ConverterWord Counter

What this tool does

Sort Lines Alphabetically turns the visible inputs on the page into a specific result and keeps the calculation context close to the form. The added notes identify what the output means, which assumptions matter, and when the result should be checked against source data or official guidance.

How to use this tool

  1. Enter the values requested by the form, keeping units, formats, and date fields consistent.
  2. Run the calculation or conversion and review each output label before using the result elsewhere.
  3. Compare important results with the page notes, examples, or official references when accuracy affects money, safety, configuration, or reporting.