Skip to content
CaseConverterHQ

Sort lines alphabetically

Paste a list, get it back in order. A to Z or Z to A, ignoring case by default, with a numeric mode for lists where the numbers should sort as numbers.

Change the case

Programmer cases

Lines and spacing

Paste some text and choose a conversion.

Words
0
Characters
0
No spaces
0
Sentences
0
Paragraphs
0
Lines
0
Read time
0 sec

Nothing you paste leaves your browser — every conversion runs on this page. Check this before you rely on it. This text converter is provided free and without warranty, and its results are not professional advice.

Alphabetical is not one order

A computer sorting text compares character codes, and in every common encoding all the capital letters come before all the lowercase ones. Sort Apple, banana, Cherry that way and you get Apple, Cherry, banana — technically correct and obviously not what anyone meant.

So the default here ignores case: Apple and apple sort next to each other, and lines that differ only by case keep a stable, repeatable order rather than shuffling. Turn on "match case" when you genuinely want byte order, which is mostly when you are comparing against another tool that does it that way, such as sort in a shell without a locale set.

Numbers sort as text unless you tell them not to

This is the one that catches everyone. Sorted as text, 10 comes before 9, because the comparison is character by character and 1 is less than 9. A list of item 1 through item 12 comes back as 1, 10, 11, 12, 2, 3 — which looks broken but is exactly what alphabetical sorting means.

Switch "compare as" to Numbers and each line is sorted by the first number in it, so item 9 lands before item 10, and -5 before 3. Lines with no number in them sort to the end, in alphabetical order among themselves, rather than being dropped or piled at the front.

What happens to duplicates and blank lines

Duplicates are kept. Sorting and deduplicating are separate operations here, unlike the shell idiom sort | uniq where deduplicating requires sorting first. If you want both, sort and then use the duplicate remover — or dedupe first, which preserves the original order for whatever comes after.

Blank lines sort to the top, because an empty string is the smallest string. If your list has stray blanks in it, run "remove extra spaces" first.

Worked example

Before

cherry
Apple
banana
apricot

After

Apple
apricot
banana
cherry

Common questions

How do I sort a list alphabetically online?

Paste one item per line and click Sort lines A to Z. Sorting ignores case by default, so Apple and apple end up next to each other rather than in separate blocks.

Why is 10 sorting before 9?

Because alphabetical sorting compares character by character, and the character 1 comes before 9. Switch the compare mode to Numbers and lines are sorted by the first number they contain.

Does sorting remove duplicate lines?

No, duplicates are kept. Use the duplicate remover for that — either before sorting, to keep the original order, or after.

Other text tools