Alphabetize a List

Paste a list and get it in alphabetical order. It sorts plain lines, comma separated items and Markdown lists, puts item 2 before item 10, can ignore a leading "the", keeps sub-items under their parent and removes duplicates.

7 items

How the sorting works

OptionOffOn
Numbers by valueitem 1, item 10, item 2item 1, item 2, item 10
Ignore a leading a, an, theA Clockwork Orange, The Beatles, ZebraThe Beatles, A Clockwork Orange, Zebra
Capitals before lowercaseapple, Apple, banana (case is ignored, original order kept for ties)Apple, apple, Banana, banana
Ignore list markersItems are grouped by their marker (-, *, 1.) before their text is compared- apple, * zebra
By last wordAda Lovelace, Alan Turing, Grace HopperGrace Hopper, Ada Lovelace, Alan Turing

Letters are compared with your browser's language rules (the Unicode collation behind Intl.Collator), not by raw character codes. That is why é sorts next to e instead of after z, and why lowercase and capital letters are mixed the way a dictionary mixes them. A plain code sort, which many tools and Array.sort() use by default, puts every capital letter before every lowercase one: Zebra before apple.

Sorting Markdown lists

Markdown lists need more care than plain lines, and this is where most line sorters go wrong:

  • Nested items. An indented line belongs to the item above it. With "Keep indented lines with the line above" on, a parent and all its sub-items move as one block. The sub-items keep their own order.
  • Numbered lists. After sorting 1. pears, 2. apples you want 1. apples, 2. pears, not the numbers shuffled along with the text. When every item is numbered, the numbers are rewritten in order, starting from the list's first number.
  • Task lists. - [x] done and - [ ] to do are sorted by their text, not by the checkbox.
  • Formatting. Leading **, _, backticks, quotes and [ are skipped, so **Bold item** and [a link](url) sort under B and A.

To fix markers and indentation afterwards, use the Markdown list formatter. The nesting rules themselves are in nested lists and sub-bullets in Markdown. To sort the rows of a table instead, convert it with Markdown to CSV, sort in a spreadsheet, and bring it back with CSV to Markdown.

Alphabetize without a tool

WhereHow
Excel and Google Sheets=SORT(A1:A100), or =SORT(UNIQUE(A1:A100)) to drop duplicates too
Shellsort -f file.txt ignores case, sort -V sorts numbers naturally, sort -u removes duplicates
Pythonsorted(lines, key=str.casefold)
JavaScriptlines.sort(new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare)

Questions

Can I sort a comma separated list?

Yes. A single line with commas is detected and sorted item by item, and the result is joined with a comma and a space. For several lines of comma separated values, tick "Items are separated by commas". To change the separator or add quotes, use the comma separator.

How do I sort names by last name?

Choose "By last word". Each line is ordered by its final word, then by the rest, so "Ada Lovelace" files under L. Names with suffixes such as "Jr." need a manual check.

Does removing duplicates ignore case?

Yes, unless "Capitals before lowercase" is on. The first occurrence is kept.

Is my list uploaded?

No. Sorting happens in your browser.

Related tools