Sort Text by Length

Paste your lines, choose shortest or longest first, and press Sort by length. You get the sorted list plus the average, minimum, maximum, and median length and a chart of how the lengths are spread.

Try an example

About this length sorter

Sorting by length puts the shortest or longest lines first, which is handy for finding outliers in a word list, tidying a list of URLs, checking which headlines are too long, or arranging names for a layout. Length means the number of characters a person sees, so an emoji or an accented letter counts once. Lines of equal length stay in the order you entered them. Alongside the sorted list you get the average, shortest, longest, and median length, and a table showing how many lines fall at each length.

How to sort text by length

  1. Paste your lines. Put one item on each line, or press an example.
  2. Choose the order. Pick Shortest to longest or Longest to shortest under Sort order.
  3. Tidy the list if needed. Tick Remove empty lines, Remove duplicate lines, or Trim spaces at the start and end of each line to clean the input before sorting.
  4. Press Sort by length. Copy or download the sorted list, and read the statistics and the distribution below it.

Frequently asked questions

What happens to lines with the same length?

They keep the order in which they appeared in your input. This is called a stable sort, and it makes the result predictable when you sort the same list more than once.

How is the length of a line measured?

In characters as a reader sees them, including spaces. An emoji or a letter with an accent counts as one character. Trim spaces first if leading or trailing spaces should not count.

When is the trim option useful?

When your lines are indented or end with stray spaces. Trimming happens before sorting, so lines that differ only by those spaces get the same length and can be removed as duplicates.

How is the median length found?

The lengths are put in order and the middle one is taken. With an even number of lines it is the average of the two middle lengths, so the median can end in .5.

How does the distribution group lengths?

Each distinct length gets its own row until there would be more than 20 rows. Then lengths are grouped into ranges of equal width so the table never has more than 20 rows.