Sort Lines by Length: Finding Long Lines and Short Examples
Finding out which title is too long or which example is shortest takes forever by hand. Sort by length and the answer is at one end of the list.
Open the tool:Sort Lines by Length
When you actually need it
Length limits are the main case, and sorting first turns the job into reading the last few lines, where the over-long entries collect. Titles, meta descriptions, ad copy, and dropdown options all have limits, and counting one by one is slow and easy to get wrong.
Teaching and writing use it too. Examples ordered shortest to longest move readers from simple to complex, and when trimming subtitles it makes sense to start with the longest lines, since they affect reading most.
- Checking character limits on titles and descriptions
- Ordering examples from short to long
- Trimming subtitles starting with the longest line
How the count works
Length is counted in characters, not display width. A Chinese character counts as 1, an emoji usually counts as 2 because it is stored as two UTF-16 code units, and spaces and punctuation count as well. A rule that means display columns will not match these numbers.
Lines of equal length keep their original relative order, because sorting in modern browsers is stable. Add a row-number column first if you want a tie-breaker. Leading spaces inflate the count, so trim the lines before sorting.
- Chinese characters count 1, most emoji count 2
- Equal lengths keep their original order
- Trim leading and trailing spaces first
Alternatives and limits
If the real question is display width, where East Asian characters take two columns and Latin letters one, preview in a monospace font or use a width tool; a character count understates how much room Chinese text takes. Counting English words is a different measure and needs splitting on spaces.
When the data lives in a spreadsheet, a LEN column sorted in place is easier to audit and keeps the other fields aligned. Sorting leaves no history, so keep a copy of the original before you start.
FAQ
Why does a line with emoji count as longer?
Many emoji are stored as two UTF-16 code units, so a character count treats each as 2. Emoji with skin tones or joined sequences can count for more, which is why emoji-heavy copy often runs longer than it looks.
Do spaces count towards the length?
Yes. Ordinary spaces, indentation, and punctuation all count, so pasted lines with leading indentation look longer. Trim the start and end of each line first for a number closer to the visible content.
How do I find the longest line quickly?
Sort ascending and the longest line is at the end. Sort descending instead and it appears first, which is handy when you want to copy it straight out and edit it.
Related tool:Sort Lines by Length