Skip to main content

Sort Lines (A–Z)

Sort lines alphabetically, ignoring case. Perfect for imports or todo lists.

Feedback

Key Features

  • Alphabetical sort (A-Z), case-insensitive
  • Handles Unicode and localized strings correctly
  • Blank lines are preserved
  • Runs client-side, works on lists of any size

Benefits

  • Organize imports, dependencies, and TODOs consistently
  • Clean up CSV or configuration files
  • Spot-check duplicates visually after sorting
  • Prepare readable lists for documentation

How to use this tool

Paste your list, one item per line

Click Process

Copy the sorted list

Sorting lines: alphabetical is not one thing

Sorting a list of lines looks like a single operation and is at least three, which is why the result sometimes looks wrong to a reader who knows what they expected.

The first distinction is byte order versus human order. Sorting by character code puts all uppercase letters before all lowercase ones, so Zebra comes before apple. That is correct by the rules a computer applies and wrong by the rules a person expects, and it is the single most common surprise. A case-insensitive sort produces the order a reader has in mind.

The second is numbers. Sorted as text, 10 comes before 9, because the comparison is character by character and 1 precedes 9. A list of files named item1 to item20 ends up in an order no human would choose. What you usually want is a natural sort, which recognises runs of digits and compares them as numbers, and it is worth checking which kind you are getting whenever a list contains numbering.

The third is accents and non-Latin scripts. Where an accented character sorts depends on the language: in French it sorts with its unaccented base letter, and in Swedish some accented letters come after z as distinct letters of the alphabet. There is no universal answer, only a locale, and a sort that ignores the question will look wrong to native readers of at least one language.

Blank lines and leading whitespace change the result more than people expect. An empty line sorts to the top in most schemes and looks like a bug. A line with a leading space sorts before every line without one, which is how a list comes back with a handful of entries mysteriously grouped at the beginning. Trimming before sorting removes both surprises.

Sorting runs in your browser tab and nothing is transmitted, which matters for the usual reason: the lists people sort are usually names, addresses or identifiers.

Frequently Asked Questions

Does it sort numbers as numbers?

Sorting is string-based, so '2' sorts before '10'. For numeric sorting, pad with leading zeros before pasting.

Related tools

Need this in a script?

The same tool answers on HTTP. Free, 1,000 calls a day, no card, and one token works across every Astral API.

POST https://astraltext.com/api/v1/sort-lines

Sort lines APIGet a free token