Home Text ToolsSort Text Lines

Sort Text Lines

Sort a list of lines alphabetically, ascending or descending.

5 lines sorted (A→Z)
Lines5
apple
apricot
banana
cherry
date

Paste a list to sort the lines alphabetically — A→Z or Z→A. Useful for tidying names, keywords, references and any line-based list.

Formula / method

sort lines alphabetically using locale-aware comparison

Examples

banana, apple, cherry (A→Z)
apple, banana, cherry
Z→A order
reverse alphabetical

Alphabetical in either direction

This tool takes a list, one item per line, and reorders it alphabetically. Ascending runs from A to Z, and descending reverses that to Z to A. It is handy for tidying up names, references, imports, to-do items or any list you want in a predictable order before sharing or comparing it. As with the other text tools here, sorting happens entirely on your device.

Blank lines and leading spaces are treated as part of the content, so trimming beforehand usually gives a cleaner result.

Text order versus number order

Sorting is lexicographic, meaning it compares characters position by position rather than understanding numeric value. That is why 10 can appear before 2, since the character 1 comes before 2. For lists of plain numbers this can surprise you; pad them with leading zeros if you need true numeric order. Capital letters may also sort before lowercase ones depending on the comparison. If your list also contains repeats you want gone, clean it first with the Remove Duplicate Lines tool, then sort.

Where it's used

  • Alphabetising a list of names, tags, or menu items
  • Ordering imports, dependencies, or config keys before a commit so diffs stay clean
  • Sorting a word or keyword list for easier scanning
  • Arranging file names or URLs into a predictable order
  • Putting survey responses or pasted CSV rows in order

Real-world examples

  • A writer sorts a 60-name attendee list A–Z to find gaps and duplicates.
  • A developer alphabetises a block of .gitignore entries so future diffs stay tidy.
  • A shopping list is sorted so related items group together for a store run.

Did you know?

Plain-text (lexicographic) sorting compares character codes, so it puts every capital letter before lowercase ones and lists '10' before '2' — because it weighs the '1' against the '2' first, digit by digit.

FAQ

How are numbers and cases handled?

Sorting is locale-aware and case-insensitive for letters. Lines that start with numbers sort by their text, so "10" comes before "9" — for true numeric order, pad numbers with leading zeros.

Related tools