Sort Text Lines

Sort text lines alphabetically, in reverse order, or randomly.

1
1
Lines: 0
Sort by
Order

Sorts lines of text A to Z, Z to A, shortest or longest first, or into a random order — for lists of names, keywords, references or anything one per line.

How to use it

  • Sort by — Alphabet, Length or Random. Each change to the text or an option shuffles a random order again.
  • Order — A → Z or Z → A by alphabet; shortest or longest first by length.
  • Ignore case — off by default: sorts “apple” and “Apple” by letter alone when on.
  • Ignore whitespace — on by default: spaces at the start of a line don't move it to the top.
  • Sort numbers by value — off by default: “item 2” sorts before “item 10” when on. By length, it orders lines of equal length.
  • Remove empty lines — on by default.

Whitespace and case affect only the comparison; each line keeps its original text. Lines that compare equal keep their original order.

How lines are ordered

Lines are compared as text using your browser's language rules, so accented letters sort next to their plain versions. Numbers sort as text, digit by digit: “10” comes before “9”. Sort numbers by value compares each run of digits as a number instead.

By length, each character a reader sees counts once, so an emoji or an accented letter is one character. With Ignore whitespace on, spaces at either end of a line don't count. Lines of equal length sort A to Z, in either direction.

Examples

Numbers sort as text

Text
item 9
item 10
item 2
A → Z
item 10
item 2
item 9
By value
item 2
item 9
item 10

Lines compare character by character, so “item 10” sorts before “item 2” unless numbers are sorted by value.

Keywords by length

Text
word counter
split pdf
qr code
merge pdf
pdf to word
Shortest first
qr code
merge pdf
split pdf
pdf to word
word counter

“split pdf” and “merge pdf” are the same length, so they sort A to Z.

See also