Skip to content
cosmodev ~/tools/sort-lines

Sắp xếp dòng & khử trùng lặp

Text & String

Sắp xếp alphabet, đảo ngược, xáo trộn, khử trùng lặp hoặc sắp xếp dòng văn bản theo độ dài. Hỗ trợ sắp xếp không phân biệt hoa thường và tự nhiên (file2 trước file10).

Thử:

(Tài liệu bằng tiếng Anh)

What it does

Sort, dedupe, reverse, shuffle, or length-sort the lines of any text. Supports case-insensitive and natural sorting (so file2 comes before file10). 100% client-side — your text never leaves the browser.

How to use it

  1. Paste text into Input (one item per line), or tap a Try: sample chip above the mode switch.
  2. Pick a mode. The result updates live on the right.
  3. Toggle the options you need.
  4. Copy the result or Download it as sorted.txt.

Modes

Mode What it does
A→Z Alphabetical, ascending
Z→A Alphabetical, descending
Short Shortest lines first (ties keep their original order)
Long Longest lines first (ties keep their original order)
Reverse Mirrors the current line order — no sorting
Shuffle Deterministic random order (seeded, see below)
Unique Removes duplicate lines, keeping the first occurrence of each. Order is preserved — Unique does not sort

Options

  • Case sensitive — off by default, so Apple and apple compare as equal and interleave freely. Turn it on to sort uppercase and lowercase strictly apart.
  • Natural sort — off by default. On, embedded numbers sort by value instead of digit-by-digit, so file2 precedes file10. Applies to A→Z and Z→A only.

The result header shows the live line count, plus the removed-duplicate count when Unique is active. Download appears only when there is output to save.

Examples

All outputs below are verified against the tool’s actual behavior.

A→Z (default, case-insensitive) — original casing is preserved, only the order changes:

banana
apple
Cherry
apple
Date

→

apple
apple
banana
Cherry
Date

Case sensitive on (input: banana, Apple, cherry, apple, Banana):

  • Off → Apple, apple, banana, Banana, cherry
  • On → apple, Apple, banana, Banana, cherry

Natural sort (input: file10, file2, file1):

  • Off → file1, file10, file2
  • On → file1, file2, file10

Unique (input: readme.md, src/, readme.md, tests/, src/, readme.md) → readme.md, src/, tests/ — 3 lines, 3 duplicates removed, first-occurrence order kept.

Short (fruit sample above) → Date, apple, apple, banana, Cherry — lengths 4, 5, 5, 6, 6 with ties keeping their original order.

Good to know

  • Private: all processing is local.
  • Unique keeps the first occurrence of each line (case-insensitively matched by default) and preserves order — it never sorts. Combine it by first using A→Z, then Unique.
  • Shuffle is seeded, so the same input gives the same order every visit (the fruit sample shuffles to Date, Cherry, apple, banana, apple).
  • Clearing the input empties the result and hides the download button.
  • Related tools: Find & Replace, Text Diff Viewer.
Mã nguồn14 ngôn ngữ

100% phía client · dữ liệu của bạn không bao giờ rời khỏi trình duyệt. Thấy hữu ích? Chia sẻ với đồng nghiệp của bạn.