AbraCalc

Sort Lines Alphabetically

Sort lines of text alphabetically (A–Z or Z–A).

Embed this tool on your site
Cite this tool

APA

AbraCalc. (2026). Sort Lines Alphabetically [Online calculator]. Retrieved from https://abracalc.com/text/sort-lines/

BibTeX

@misc{abracalc-sort-lines, author = {AbraCalc}, title = {Sort Lines Alphabetically}, year = {2026}, howpublished = {\url{https://abracalc.com/text/sort-lines/}} }

Did this tool answer your question?

How to use this tool

  1. Enter text and order in the fields above.
  2. Results update instantly as you type — or click Calculate.
  3. Read your sorted text and the full breakdown beneath it.

Sort lines of text alphabetically (A–Z or Z–A).

How it works

This tool sorts the lines of your text in alphabetical order, either A to Z or Z to A, using a case-insensitive comparison so that lines beginning with uppercase and lowercase letters are interleaved naturally rather than grouped by case. Each line of the input is treated as a single sortable unit.

Paste any list — countries, names, ingredients, file names, CSS properties, dictionary entries — into the Text field, choose the direction, and receive the sorted list. This is faster than sorting by hand and more reliable than spreadsheet sorting when your data is plain text rather than tabular.

The sort is lexicographic for text. Numbers at the start of lines are sorted as strings by default, which means '10' comes before '2'. If you need numeric sort order, prefix numbers with leading zeros before sorting.

Worked example

Alphabetise a grocery list

  1. Paste the list with one item per line: milk, Apples, broccoli, Zucchini, eggs.
  2. Select Order: A to Z.
  3. The tool sorts case-insensitively.
  4. Read the sorted result.

Apples broccoli eggs milk Zucchini

Common mistakes to avoid

  • Sorting a numbered list and finding '10' appears before '2' — this is correct lexicographic behaviour; add leading zeros to fix it.
  • Sorting lines that have trailing spaces, which can cause inconsistent grouping — run the Remove Extra Spaces tool first.
  • Expecting the sort to be stable for lines that compare equal — equal lines may appear in any order in the output.

Key terms

Lexicographic order
Alphabetical ordering based on character codes, used here for sorting text lines.
Case-insensitive sort
A sort that treats uppercase and lowercase versions of the same letter as equal, so 'apple' and 'Apple' sort together.

Frequently asked questions

Does sorting preserve blank lines?
Yes — blank lines are treated as empty strings and sort before any letter.

References & sources