Skip to content

Sort Lines Alphabetically

Sort the lines of a list alphabetically, by number, by length, or in natural order such as file2 before file10.

Line sorter
One item per line. Choose how to sort.

Result
Sorted lines
10
9
Apple
banana
cherry
pear
6
Lines

Private: Everything runs in this page. Nothing you type is sent anywhere or saved.

On this page
  1. Sorting examples
  2. Formula
  3. How the line sorter works
  4. What this tool does not do
  5. Frequently asked questions
  6. Related tools

Sorting examples

LinesSorted byResult
pear, Apple, figazApple | fig | pear
pear, Apple, figzapear | fig | Apple
file10, file2, file1naturalfile1 | file2 | file10
10, 9, 100num9 | 10 | 100
ccc, a, bblengtha | bb | ccc

Formula

A to Z compares the lines letter by letter

How the line sorter works

  1. Step onePaste your list with one item on each line.
  2. Step twoChoose the sort order. Natural order treats the number inside a name as a number.
  3. Step threeCopy the sorted list from the box.

What this tool does not do

  • Alphabetical order here follows character codes, not the rules of a language, so accented letters sort after plain ones.
  • Number sort reads the number at the start of a line only.
  • It does not remove duplicate lines; use the duplicate remover for that.

Frequently asked questions

Why does plain A to Z put file10 before file2?

Letter-by-letter order compares the character 1 with 2 first. Choose natural order to sort the numbers inside names the way people expect.

What happens to lines that are not numbers in number sort?

They are placed at the end, in their original order.

Is the sort stable?

Yes. Lines that compare as equal keep the order they had.