Skip to main content
Tools

Sort Lines

Sort lines alphabetically, naturally (file2 before file10), by number or length, reverse them or shuffle them randomly.

Order

0 characters · 1 line

How to use

  1. Paste a list into “Your text”, one item per line, or click “Example” to try it out.
  2. Choose how to sort: alphabetical, natural, by the first number, by length, reverse the current order, or shuffle.
  3. Pick ascending or descending. For Chinese, choose stroke count, Zhuyin or Pinyin under “Dictionary”.
  4. The result appears instantly on the right (below on phones). Click “Copy” or “Download” to grab it.

FAQ

Is my data uploaded?

No. Sorting happens in your browser and your data never leaves your device.

How is Chinese sorted?

With the browser’s built-in collation (Intl.Collator). “Chinese stroke count” orders characters from fewest to most strokes, which is common in Taiwan (for example in name lists); “Zhuyin” follows Bopomofo order; “Hanyu Pinyin” follows Pinyin spelling. These three put Chinese before Latin letters; “English (Latin first)” puts Latin letters first and Chinese after them. If a browser lacks Zhuyin or Pinyin data, a notice appears and stroke order is used.

What is the difference between alphabetical and natural sorting?

Alphabetical sorting compares character by character, so file10 comes before file2 (1 is less than 2). Natural sorting reads runs of digits as numbers, giving file1, file2, file10. It also works for version numbers such as v1.9 and v1.10.

How does “First number in line” work?

It finds the first number in each line (minus signs, decimals, thousands separators and full-width digits are understood) and sorts by its value. Lines without a number always go last; equal numbers are ordered by text.

How is upper and lower case handled?

By default case is ignored: apple and Apple are equal and keep their original order. With “Case-sensitive”, capitals come before lowercase versions of the same letter. “Unicode code points” sorts by character code, so with case sensitivity all capitals come before all lowercase letters.

How is length measured?

In visible characters: a Chinese character, a letter and an emoji such as 👍🏽 each count as 1. Lines of equal length keep their original order.

How random is the shuffle?

It uses the browser’s cryptographically secure random numbers (crypto.getRandomValues) with a Fisher–Yates shuffle, so every order is equally likely, which makes it fine for drawing lots or forming groups. Click “Shuffle again” for a new order.

Keyboard shortcuts

/
Search tools (on a tool page, goes to the homepage search)
?
Show this help
Esc
Close a dialog
Ctrl / ⌘Enter
Run the tool's main action (where supported)

While you type in a text field, / and ? are typed as usual.