Sort Lines by Length

Sorts a list so the shortest or longest lines come first. It is useful for tidying word lists, spotting the longest title or heading in a set, or putting short items at the top of a list before you paste it elsewhere.

Up to 1 MiB.

Options

How to use the Sort Lines by Length

  1. Paste a list with one item per line.
  2. Choose Shortest first or Longest first.
  3. Turn on Sort lines of equal length alphabetically for a predictable order of ties.

Rules applied

  • Length is measured in visible characters: an emoji or an accented letter counts as one.
  • Lines of equal length keep their original order unless alphabetical ordering is on.

Limitations

  • Characters are counted, not their display width: wide characters such as Chinese count as one.

Worked examples

Shortest first

Input

elephant
cat
hippopotamus
emu 🐦
bee

Result

cat
bee
emu 🐦
elephant
hippopotamus
Longest first

Input

a
abc
ab

Result

abc
ab
a

Practical uses

  • Spotting the longest list entries

    An editor pastes a list of headlines and chooses Longest first. The entries most likely to be cut off in a page layout appear at the top. The editor can then shorten those first and leave the shorter ones alone.

  • Ordering a word list for a puzzle

    A teacher building a word-search puzzle pastes the vocabulary list and chooses Shortest first. Turning on alphabetical order for lines of equal length keeps ties in a predictable order. The grid is then easy to plan, with the short words placed first and the longest ones kept in view.

Privacy: this tool runs entirely in your browser. Your text is not uploaded, logged or saved, and it is never sent to analytics. Maximum input: 1 MiB.