Alphabetical order is the default way to arrange a list, but it answers only one question: what comes first in the dictionary. Sometimes the question is different. Which of these headlines is the shortest? Which product name is the longest? Which entries in this list are the odd ones out because they run far longer than the rest? For those questions you want the list arranged by length, and counting characters by hand is slow, dull work.

This guide shows how to sort a list by length with the free Sort Lines Tool on Ovatly, using its shortest first and longest first modes. It also covers the one rule that decides every result in these modes: length is measured in characters, including spaces. That single detail explains most surprises.

Contents

  • Quick answer
  • When length order beats alphabetical order
  • How length is counted: characters, including spaces
  • The two length modes
  • How to sort a list by length, step by step
  • Worked example: a drinks list by length
  • Limitations and alternatives
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Open the Sort Lines Tool, paste your list with one item per line, and choose shortest first or longest first. The tool rearranges the lines by their character count, spaces included, and you copy or download the result. Shortest first surfaces your briefest entries at the top; longest first puts the longest line at the top, which is the fastest way to spot entries that run long. Nothing is uploaded: the sorting happens in your browser.

When length order beats alphabetical order

Length order earns its place whenever the size of an entry matters more than its name. A few everyday cases:

  • Fitting text into tight slots. Labels, button text, menu items and headlines often have practical length limits. Sorting shortest first shows you at a glance which entries are safely brief and which need trimming.
  • Spotting outliers. In a list of product names, file names or titles, one entry that is twice as long as the rest usually signals a naming mistake or an entry that picked up extra words. Longest first brings it straight to the top.
  • Checking consistency. Lists that are supposed to follow a pattern, such as short codes or fixed-style names, reveal their strays when sorted by length: the entries that break the pattern collect at one end. None of this replaces alphabetical order for lookup. If someone will search the list by name, A to Z is still the right finish. Length sorting is a working view: use it to inspect and fix the list, then sort alphabetically at the end if the final audience needs that.

How length is counted: characters, including spaces

The rule is simple and worth memorising, because it predicts every result: length is measured in characters, and spaces count as characters.

That means a multi-word entry is longer than it looks. The phrase "green tea" is 9 characters: seven letters plus the space between them plus nothing else. A single word like "espresso" is 8 characters. So in a length sort, "green tea" ranks as the longer line, even though it has fewer letters. Leading or trailing spaces pasted in with your text would count too, since they are characters like any other, which is one reason a quick tidy of the pasted list pays off before you sort.

Two consequences follow. First, judge the result by character counts, not by how long a line looks on screen, because proportional fonts make wide and narrow letters look deceptively different. Second, if two lines sit in an unexpected order, count their characters including spaces before assuming the sort went wrong; the count is almost always the explanation.

The two length modes

The tool offers seven sort modes in total: A to Z, Z to A, numeric low to high, numeric high to low, shortest first, longest first, and reverse order. The two length modes are a matched pair.

Shortest first arranges lines from the fewest characters to the most. It is the mode for finding your most compact entries: the shortest headline, the briefest label, the tightest version of a name.

Longest first arranges lines from the most characters to the fewest. It is the inspection mode: the longest entries sit at the top where you cannot miss them, ready to be trimmed, renamed or questioned.

A common pattern is to sort longest first to fix the outliers, then switch to A to Z for the final, presentable order, all without pasting the list again.

How to sort a list by length, step by step

  1. Open the Sort Lines Tool.
  2. Paste your list, one item per line. If the list came from a spreadsheet column or a document, check that each entry sits on its own line.
  3. Choose shortest first or longest first as the sort mode.
  4. Read the sorted result below.
  5. Copy or download the sorted lines.

Before step 3, one optional preparation helps: if your list may contain repeated lines, remember that this tool does not remove duplicates. Run the list through Remove Duplicate Lines first if a clean set matters, then sort.

Worked example: a drinks list by length

Take this pasted list of drinks, in no particular order:

Hot chocolate
Tea
Espresso
Fig juice
Green tea
Coffee

First, the character counts, spaces included: "Hot chocolate" is 13, "Tea" is 3, "Espresso" is 8, "Fig juice" is 9, "Green tea" is 9, and "Coffee" is 6.

Sorted with shortest first, the result is:

Tea
Coffee
Espresso
Fig juice
Green tea
Hot chocolate

Sorted with longest first, the order flips: "Hot chocolate" (13) leads, the two 9-character entries follow, then "Espresso" (8), "Coffee" (6) and "Tea" (3).

The example shows the spaces rule in action twice. "Fig juice" and "Green tea" both count 9 characters even though one has eight letters and the other seven; their spaces make up the difference. If this list were meant to be short counter labels, "Hot chocolate" stands out at once at the top of a longest-first sort, four characters clear of everything else.

Limitations and alternatives

Sorting by length tells you about size and nothing else. It says nothing about importance, quality or correctness, and it will happily put a meaningless short line above a useful long one. Treat the order as a lens, not a judgement.

The tool also has clear edges. It does not remove duplicates, so repeated lines stay repeated in the output, just reordered. It does not edit lines: spelling, spacing inside a line and punctuation all survive exactly as pasted, which means stray spaces inside your text are counted rather than cleaned. And the length measure is characters, not words or display width, so it cannot tell you how wide a line will render in a particular font.

For the neighbouring jobs, the Text and Writing Tools guide archive collects the companion pieces on cleaning a messy list before sorting and removing duplicate lines. If your real question is about the numbers lines start with, the numeric modes of the same tool are the better fit, and if it is about dictionary order, A to Z with its natural number handling is the one to use.

Common mistakes

  • Forgetting that spaces count. Expecting "green tea" to rank by its seven letters, then thinking the sort is broken when it ranks as nine characters.
  • Judging length by eye. Proportional fonts make lines of equal character count look different lengths. Trust the count.
  • Sorting a list with duplicates still in it. Length modes reorder duplicates like everything else; dedupe first if repeats are not wanted.
  • Leaving stray spaces in the paste. Trailing spaces copied from a spreadsheet count as characters and can nudge a line's rank. A quick tidy first keeps results honest.
  • Using length order as the final order for readers. People look things up alphabetically. Use length order to inspect, then re-sort A to Z for the published list.

FAQs

How is the length of a line measured? In characters, including spaces. A line like green tea counts as 9 characters, not 7 letters, because the space between the words counts too.

What is the difference between shortest first and longest first? Shortest first puts the line with the fewest characters at the top and works down to the longest. Longest first reverses that, putting the longest line at the top.

Can it remove duplicates while sorting? Not directly. Run the list through Remove Duplicate Lines first, then sort the cleaned result here.

Does sorting change the lines themselves? No. Only the order changes; every line keeps its exact original text.

Is my list uploaded? No. Sorting happens in your browser on your device.

Conclusion

Sorting by length answers the questions alphabetical order cannot: which entries are shortest, which are longest, and which are quietly out of line with the rest. With the Sort Lines Tool, the whole job is a paste, a mode choice and a copy, and the only rule to remember is that length means characters, spaces included. Use longest first to inspect, shortest first to find your most compact entries, and A to Z when the finished list goes to readers. For the classic way numbers go wrong in a sorted list, and how this tool's natural and numeric ordering fix it, read the companion guide: Sorting Mistakes: Why Numbers End Up in the Wrong Order.