Sort Lines by Length
Sort Lines by Length places shorter lines before longer ones using displayed grapheme counts.
Example: sort lines by length
long hi
hi long
How to use this tool
- Put each item on a separate line.
- Run Sort Lines by Length.
- Inspect edge spaces and equal-length items before using the result.
How the result is made
The tool counts grapheme clusters in each line and sorts ascending by that count. “hi” moves before “long”. It does not trim spaces, so leading and trailing spaces add to length. Equal-length lines keep their relative order under modern stable JavaScript sorting.
When to use it
Use it to find unusually short or long labels, prepare a size-ordered list, or compare text samples at a glance. Character Counter measures one text block, while this tool reorders whole lines. Alphabetical and Natural Sort use content order rather than length.
Details to check
A grapheme count is closer to visible character units than UTF-16 length, but rendering width is not the same as character count. An emoji or wide CJK character may occupy more visual space than a Latin letter. Trim Lines first if edge spaces should not count.
Questions people ask
Does it count bytes?
No. It counts grapheme clusters.
Do spaces count?
Yes, including spaces at line edges.
Is shortest first?
Yes. The current sort is ascending only.