Sort Lines Alphabetically

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free tool to sort lines alphabetically, from Z to A, by length or in natural number order. Remove duplicates or shuffle the list too.

Sorted list

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to sort lines alphabetically

Paste a list into the box, one item per line, and choose an order. The tool sorts lines alphabetically from A to Z by default, and the sorted list appears below, ready to copy. You can also choose:

  • Z to A, reverse alphabetical order.
  • Shortest first and Longest first, by number of characters.
  • Reverse the current order, which flips the list upside down without sorting it.
  • Shuffle randomly, which mixes the list into a random order.

Three options refine the result:

  • Case sensitive. Off by default, so "apple" and "Apple" sort together. Turn it on for strict computer-style ordering, where all capital letters come before lowercase ones.
  • Remove duplicates. Keeps one copy of each line.
  • Remove empty lines. On by default, so blank lines don't collect at the top of the list.

Sorting happens in your browser. Nothing you paste is uploaded or stored.

Natural sorting: why "item 2" comes before "item 10"

Many simple tools sort lines alphabetically character by character, which gives odd results with numbers: "item 10" comes before "item 2", because the character "1" comes before "2". This tool uses natural sorting, which reads numbers inside text as whole numbers. So:

Simple sort Natural sort (this tool)
item 1 item 1
item 10 item 2
item 11 item 3
item 2 item 10
item 3 item 11

That's what people expect when sorting file names, chapter titles, product codes, invoice numbers and addresses.

How letters are compared

When you sort lines alphabetically without the case-sensitive option, the tool compares text the way a dictionary does:

  • Capitals and lowercase sort together. "apple", "Apple" and "APPLE" sit next to each other.
  • Accented letters sort with their base letter. "Émile" sorts among the E words, not after Z.
  • Language-aware ordering. The comparison uses your browser's language settings, so letters such as "ñ", "ø" or "ß" are placed where readers of that language expect them.

With case sensitive on, the tool compares the raw character codes instead. That puts all uppercase letters before all lowercase ones ("Banana" before "apple") and is useful when you need the same order a computer program or a database would produce.

Sorting by length

Length sorting counts characters in each line, shortest first, with alphabetical order as a tie-breaker. It's handy for:

  • finding the longest product titles or headlines that might be cut off,
  • spotting unusually short entries in a list, which are often mistakes,
  • arranging tags or keywords for a visual layout.

Choose Longest first to put the longest lines at the top.

What people sort

  • Keyword lists for SEO and ads, to group similar terms and spot near-duplicates side by side.
  • Glossaries and FAQs, so readers can find terms quickly.
  • Guest lists, team lists and directories.
  • Product catalogues, ingredient lists and menus in alphabetical order.
  • Bibliographies and reference lists.
  • File names and code such as import statements or configuration keys.
  • Content ideas, before you decide which to schedule.

A worked example

You have a list of menu items pasted from a supplier's email, in no particular order:

Seeded rye 800g
almond croissant
Sourdough 1kg
Cinnamon bun
Seeded rye 400g
baguette

With the default settings, choosing A to Z gives:

almond croissant
baguette
Cinnamon bun
Seeded rye 400g
Seeded rye 800g
Sourdough 1kg

Lowercase and capitalized items sit together in true alphabetical order, and "400g" comes before "800g" because the numbers are compared as numbers. With "Case sensitive" switched on, the capitalized items would all come first and "almond croissant" and "baguette" would drop to the bottom, which is rarely what you want for a menu or a list people will read.

Why sorted lists help readers

Alphabetical order is the one order everyone already knows, so readers can find an item without reading the whole list. That's why glossaries, directories, ingredient lists, indexes and dropdown menus are almost always sorted. When you sort lines alphabetically before publishing a list, you save every reader a little time. For lists where something else matters more, such as price, popularity or the order of steps, keep that order instead and say so in the heading.

Sorting names by surname

Lines are sorted by their first character, so a list of "First Last" names sorts by first name. To sort lines alphabetically by surname, the names need to be written "Last, First" first. If your list is long, you can rearrange it with find and replace using a regular expression:

  • Find: ^(\S+) (\S+)$
  • Replace: $2, $1
  • Tick "Regular expression"

"Maya Chen" becomes "Chen, Maya". Sort the result, and the list is in surname order. (Names with middle names or two-part surnames will need a quick manual check.)

Tips for sorting lists well

  • Decide what "the start" of each line is. Lines are compared from the first character, so a list of "The Bakery", "A Cafe" and "Bean There" sorts by "The" and "A". Library catalogues often move leading articles to the end ("Bakery, The") before sorting; do the same if it matters for your list.
  • Keep a consistent format. "Dr Smith" and "Smith, Dr" won't sort together. Settle on one format first.
  • Check the top and bottom. Lines starting with symbols, quotes or numbers sort before letters, so stray punctuation tends to collect at the top of a sorted list, which makes it easy to spot.
  • Sort a copy. If the original order carried meaning, keep it somewhere before you sort lines alphabetically.

Shuffling a list

The shuffle option uses a fair random shuffle, so every order is equally likely. It's useful for:

  • picking a random order for presentations or interview slots,
  • randomizing quiz questions or survey options so position doesn't bias answers,
  • drawing a winner from a list of entries (take the first line after shuffling).

Each time you change an option or edit the list, the order is shuffled again. If you need a record of a draw, copy the result immediately.

Combining sort with other clean-up

  • Remove duplicates in the original order: use remove duplicate lines if you don't want the list sorted.
  • Clean spacing first: lines that start with a space sort before everything else. The "remove empty lines" option drops blank lines, but for leading spaces and invisible characters, run the list through remove extra spaces first.
  • Join lines broken by a PDF: if one item is split across two lines, use remove line breaks carefully before sorting.
  • Compare two sorted lists: sorting both, then using text compare, makes it easy to see which items are in one list but not the other.

Sorting in spreadsheets and editors

  • Excel and Google Sheets: select a column and use Data, then Sort A to Z. For formulas, =SORT(A2:A) works in both. Spreadsheets sort numbers stored as numbers correctly, but text with numbers inside ("item 10") still sorts character by character.
  • Microsoft Word: select the lines, then Home, then the Sort button (A to Z with an arrow).
  • Code editors such as VS Code have a "Sort Lines Ascending" command.

For a quick list from an email, website or chat, pasting it here to sort lines alphabetically is faster than opening a spreadsheet, and the natural sorting handles numbers inside text the way people expect.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.

Frequently asked questions

How do I sort lines alphabetically?

Paste your list with one item per line, leave the order on "A to Z", and copy the sorted result. Choose "Z to A" for reverse order.

Does the tool sort numbers correctly?

Yes. It uses natural sorting, so numbers inside text are compared as whole numbers and "item 2" comes before "item 10".

Is the sort case-sensitive?

Not by default; capital and lowercase letters sort together. Turn on "Case sensitive" for strict ordering where all capitals come first.

Can I remove duplicates while sorting?

Yes. Tick "Remove duplicates" and only one copy of each line is kept in the sorted list.

Is my list stored or sent anywhere?

No. Sorting happens in your browser, and nothing is uploaded or saved.

How do I sort a list in reverse without sorting it alphabetically?

Choose "Reverse the current order". The last line becomes the first, without changing anything else.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep