Skip to content
UniKit

Sort list by length

Sort every line by its Unicode code-point length, ascending or descending — one Chinese character counts as 1 and one emoji as 1 (not UTF-16 units) — ties keep their original order, with min/max/average and a per-line length breakdown.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

List

Sorted list

One item per line, lengths counted in Unicode code points.

Paste a list to sort it by length

Lines: 0 · Shortest: 0 · Longest: 0 · Average length: 0

What this tool does

  • Inspect the length distribution of a column: the shortest and longest lines end up next to each other so outliers stand out.
  • Prepare fixed-width layout: sort by length first, then decide what to truncate or pad.
  • Order a list by name length for aligned display or an export into a monospaced table.

Example

Input

banana
kiwi
apple

Output

kiwi
apple
banana

Ascending code-point length: kiwi and the two-character Chinese words sort first, and equal lengths keep their input order.

Frequently asked questions

How are Chinese characters and emoji counted?

By Unicode code point: one Chinese character is 1 and one emoji is 1, so “你好” is length 2 and “🙂” is length 1. That differs from JavaScript's `str.length`, which counts UTF-16 units and scores an emoji as 2.

Do equal lengths get shuffled?

No. The comparator falls back to the original line number when lengths are equal, so equal-length lines keep their exact input order (a stable sort). Turn on “Break ties by content” to sort those by code point too.

How do I switch direction?

Ascending (shortest first) is the default; set the order to “longest first” for descending. In descending order equal lengths still keep their input order, just inside the reversed block.

Do blank lines and indentation count?

Blank lines are dropped by default, and “Trim each line” is on, so lengths are measured after trimming and the output is trimmed too. Turn trimming off if the indentation should count.

Keywords:按长度排序sort by length列表排序短到长长到短文本长度码点长度行长排序

Related tools