Home / Text tools / Sort lines alphabetically

Sort Lines Alphabetically

Put your lines in A to Z order. Sort by the whole line, the first word or the last word.

How alphabetical sorting works

Lines are compared letter by letter using the sorting rules of your browser language. That means accented letters such as é and ö sit next to their plain forms, instead of being pushed to the end as they would be in a raw character-code sort.

Case and accents

By default case is ignored, so Apple, apple and APPLE sort together. Tick Case sensitive to separate them, with the capital form first, so A comes before a. Tick Ignore accents if you want café and cafe treated as the same word.

Sort by the first or last word

Sometimes the whole line is not the right key. Choose Last word to sort a list of full names by surname, or First word to group lines by a leading keyword. Lines with the same key keep a sensible order by comparing the whole line next.

Example

The names Maria Lopez, anna Smith, John Adams, Zoe Baker, Ben carter and Ali Hassan sorted by last word become John Adams, Zoe Baker, Ben carter, Ali Hassan, Maria Lopez, anna Smith.

Where it helps

Sort a bibliography, a glossary, a list of names, keywords, tags, product names, CSS properties or import statements. Remove duplicates at the same time to tidy long lists.

For other methods use the main sort lines tool, or go the other way with reverse order. See the guide for command line and spreadsheet methods.

Frequently asked questions

Is the alphabetical sort case sensitive?

Not by default. Tick Case sensitive to treat capitals and lowercase letters as different. The capital form is listed first, so A comes before a.

How do I sort names by surname?

Choose Sort by: Last word. Each line is ordered by its final word.

How are accented letters sorted?

They sort next to their plain letters. Tick Ignore accents to treat them as identical.

How do I sort Z to A?

Set the direction to Descending.