ListFerret mascot

Home › Guides › How to Sort a List Alphabetically (Online, Excel, Sheets)

How to Sort a List Alphabetically: Online, Excel, Google Sheets and Notepad++

Sorting a list alphabetically sounds trivial until the result looks wrong: “Item 10” lands before “Item 2”, capital letters jump to the top, or numbers sort as text. This guide shows how to sort a list alphabetically in a browser tool, in Excel and Google Sheets, in a text editor and on the command line, and explains why those surprises happen.

The quick answer

Sort a list alphabetically online

When your list is in an email, a document or a web page, a browser tool is the quickest route:

  1. Paste your list into Sort Lines, one item per line. If your items are separated by commas or something else, change the input separator.
  2. Choose the order: A → Z, Z → A, natural, numeric, by length, reversed or shuffled.
  3. Optionally tidy the list at the same time: trim spaces, remove blanks and duplicates, change the case, or add quotes and numbers.
  4. Copy the result or download it as a text file.

Nothing is uploaded; the sorting happens in your browser, so private lists stay on your device.

Which sort order do you need?

“Alphabetical” is only one of several orders, and picking the wrong one causes most sorting problems. Here is the same list sorted three ways:

OriginalA → Z (alphabetical)Natural
banana
Item 10
apple
Item 2
Cherry
Item 1
apple
banana
Cherry
Item 1
Item 10
Item 2
apple
banana
Cherry
Item 1
Item 2
Item 10

Plain alphabetical order compares character by character, so “Item 10” comes before “Item 2” because the character 1 comes before 2. Natural sorting reads the digits as a whole number, which puts the items in the order a person expects. Use natural sorting for anything with numbers inside the text, such as file names, versions and product codes.

Sort in Excel

For a one-off sort, select the column and use Data → Sort A to Z. Excel offers to expand the selection to neighbouring columns so that rows stay together; choose that unless you really want to sort one column on its own.

If you want a live, sorted copy that updates when the source changes, Excel 365 and Excel 2021 have the SORT function:

=SORT(A2:A100)

Add a second argument of -1 to sort Z to A: =SORT(A2:A100, 1, -1). Excel’s sorting ignores letter case, so “apple” and “Apple” sort together.

Sort in Google Sheets

=SORT(A2:A100, 1, TRUE)

The second argument is the column to sort by, and TRUE means ascending. Use FALSE for Z to A. To sort in place instead, select the range and choose Data → Sort range, then pick the column and direction.

Sort in a text editor

EditorHow
Notepad++Edit → Line Operations → Sort Lines Lexicographically Ascending (or Descending)
Visual Studio CodeOpen the Command Palette (Ctrl+Shift+P) and run Sort Lines Ascending
Sublime TextEdit → Sort Lines (shortcut F9)

Notepad++ calls its alphabetical sort “lexicographic”, which compares character codes. That puts all capital letters before lowercase ones, so “Cherry” can appear before “apple”. If that is not what you want, sort with a tool that ignores case.

Sort on the command line

WhereCommand
Linux or macOSsort list.txt. Add -f to ignore case, -n for numeric order, -r to reverse, -u to remove duplicates, and -V for natural “version” order on GNU systems.
PowerShellGet-Content list.txt | Sort-Object. Add -Descending to reverse and -Unique to remove duplicates.

Results from sort can depend on your system’s language and locale settings, which control how capitals and accents are ordered. If the order looks odd, that is usually the cause.

Fixing common sorting surprises

Frequently asked questions

How do I sort a list alphabetically online?

Paste the list into Sort Lines, one item per line, and choose A → Z. Copy the result or download it. The sorting runs in your browser and nothing is uploaded.

How do I sort a list alphabetically in Excel?

Select the column and choose Data, then Sort A to Z. In Excel 365 you can also use the formula =SORT(A2:A100) to get a live sorted copy.

How do I sort a list alphabetically in Google Sheets?

Use =SORT(A2:A100, 1, TRUE) for a sorted copy, or select the range and choose Data, then Sort range.

How do I sort lines alphabetically in Notepad++?

Choose Edit, Line Operations, then Sort Lines Lexicographically Ascending. It sorts by character code, so capital letters come before lowercase ones.

Why does 10 come before 2 when I sort?

Alphabetical sorting compares characters one at a time, and the character 1 comes before 2. Use numeric sorting for plain numbers, or natural sorting when numbers are part of the text.

What is natural sort order?

Natural sort order reads runs of digits as whole numbers, so Item 2 comes before Item 10. It is the order most people expect for file names and version numbers.

Try it now: use the free Sort Lines - private, instant and runs in your browser. Open Sort Lines →

More guides

Share this page: XFacebookLinkedInRedditEmail