Character-count sort with alphabetical tiebreak
Each line's `.length` drives the sort - `"kiwi"` (4 chars) before `"apple"` (5) before `"grapes"` (6) before `"banana"` (6, tied with grapes but sorts later alphabetically). Stable output: same input always yields the same sorted list.
Order defaults to ascending (shortest first). Flip to descending for longest first. Case sensitive only matters on the alphabetical tiebreak for items of identical length: off (default) treats `Apple` and `apple` as equal under base-sensitivity `localeCompare`, so the stable sort keeps them in their input order; on distinguishes them so they sort as separate tied items. It has no effect on the length comparison itself - two items of different length sort the same either way.
For finding just the shortest or longest N items, chain Head (keeps first N) after this sort. For the raw extremes metric, use Find longest and shortest.
How to use sort list by item length
- 1Paste your list into the input panel
- 2Default Mode is By length (Order ascending)
- 3Flip Order to descending for longest-first
- 4For just the N shortest / longest items, chain Head
- 5Case sensitive only affects the alphabetical tiebreak on equal-length items (off = `Apple`/`apple` equal, stable; on = distinguishable)
Keyboard shortcuts
Drive ListShift without touching the mouse.
What this tool actually does
Pre-configured By-length variant of Sort a list.
Character-count sort
Compares `line.length` - the raw character count. Unicode surrogate pairs (emoji) count as 2 in JavaScript, which can surprise you if your input has astral-plane characters.
Alphabetical tiebreak
Two items of the same length fall back to `localeCompare` ordering. Keeps output predictable and stable across runs.
Ascending default
Shortest first. Flip Order for longest first - useful when hunting for outlier-long rows in a log dump.
Works on any text
Paste words, lines of code, URLs, sentences - the op is content-agnostic. Measures whatever text is on each line.
Stable sort since ES2019
Identical length + identical alpha tiebreak → original relative order preserved. Safe to re-run without churn.
Worked example
Default: Mode By length, Order ascending. `kiwi` (4) first; `banana` and `grapes` tied at 6 - alpha tiebreak puts `banana` first.
apple banana kiwi grapes
kiwi apple banana grapes
Settings reference
Explore how each option affects the output using the sample input.
| Setting | What it does | Effect on the sample |
|---|---|---|
| Order: Ascending (default) | Sorts items from shortest to longest; alphabetical tiebreak on equal-length items | kiwi apple banana grapes |
| Order: Descending | Sorts items from longest to shortest; alphabetical tiebreak still applies on equal-length items | banana grapes apple kiwi |
| Case sensitive: On | Only affects the alphabetical tiebreak when two items have the same length; distinguishes `Apple` from `apple` as separate tied items. Does not affect the length comparison itself. | No visible change on this sample - all items are lowercase and no two same-length items differ only in case. On an input like `[Apple, apple, PEARS, pears]` the toggle would matter. |