TToolbox
⇕

Text Sorter

Sort, reverse or shuffle lines

About this tool

Sorting multi-line text datasets is a recurring requirement across keyword research, glossary compilation, code variable alignment, and log organization. Naive ASCII sorting produces counter-intuitive outcomes: uppercase letters segregate from lowercase, while alphanumeric filenames order as `item10` before `item2`. This tool delivers multidimensional sorting algorithms—natural human sorting, alphabetical A-Z / Z-A, line length sorting, and mathematically unbiased Fisher-Yates random shuffling.

How to Use This Tool (Step-by-Step)

1

Paste Multi-Line Text List

Paste your raw list of words, names, log lines, or code identifiers into the main text pane.

2

Select Sorting Algorithm

Choose your target sorting logic: A-Z, Z-A, Natural Numerical Sort, Line Length (short to long), or Random Shuffle.

3

Inspect Sorted Order & Copy

The sorted list updates instantaneously. Review the ordered lines and copy the clean output directly with one click.

Intl Natural Sorting Engine

Employs modern `Intl.Collator` to parse multi-digit numbers embedded in text naturally (`item2` precedes `item10`).

Unbiased Fisher-Yates Shuffle

Randomization uses the provably unbiased Fisher-Yates shuffle, ensuring uniform distribution for random sampling.

100% Client-Side Privacy

Sorting executes entirely inside local browser memory. Internal employee directories and password wordlists are never uploaded.

List Sorting Best Practices & Tips

  • •Trim whitespace before sorting: Leading spaces (ASCII 32) float lines to the very top of alphabetical sorts. Always trim first.
  • •Sorting Chinese by Pinyin: Initializing `Intl.Collator('zh-CN')` automatically sorts Chinese characters alphabetically by their Pinyin transliteration.
  • •Pair sorting with deduplication: Sorting lists brings duplicate entries adjacent to each other, making subsequent deduplication instantaneous.

Code & Transformation Examples

ASCII Sort vs Natural Sort Benchmark

Raw Input
file10.txt
file1.txt
file2.txt
File20.txt
Natural Sort Output
file1.txt
file2.txt
file10.txt
File20.txt

* ASCII sorting fails by comparing characters by byte (`1` < `2`). Natural sorting understands numeric magnitude.

JavaScript Sorting Implementations Snippet

Natural Sort Snippet
const lines = ["img10.png", "img2.png", "img1.png"];
// 使用标准国际化对比器
lines.sort(new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare);
console.log(lines); // ["img1.png", "img2.png", "img10.png"]
Sort by Line Length
lines.sort((a, b) => a.length - b.length);
// 短行在前,长行在后

* `Intl.Collator` is the browser-native internationalization interface for locale-aware string sorting.

Frequently Asked Questions

Q: Is random shuffle mathematically unbiased?

A: Yes. Fisher-Yates shuffles in-place by picking random elements from unvisited indices. Every permutation has identical mathematical probability.

Q: In case-sensitive mode, does uppercase or lowercase come first?

A: In standard ASCII sorting, uppercase A-Z (codes 65–90) precedes lowercase a-z (codes 97–122). `Apple` naturally precedes `banana`.

Q: Can this tool sort tens of thousands of lines smoothly?

A: V8's native TimSort algorithm processes 50,000 lines in under 50 milliseconds. Memory allocation and DOM renders are optimized for high throughput.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/