When do you need to sort lines?
Sorting lines is a surprisingly common task for developers, writers, and data workers alike. You might want to alphabetize a list of country names, sort CSS properties for consistency, order a set of imports, arrange log lines by length for quick scanning, or shuffle a list of test inputs for randomization. Command-line users reach for sort(1) — but that requires a terminal. ServoDev's sort tool runs entirely in the browser and updates instantly, with five sort modes and two filtering options.
How to use this tool
- 1 Paste your lines of text into the Input panel — the line count appears in the header.
- 2 Choose a sort mode: A → Z (alphabetical), Z → A (reverse alphabetical), By length (shortest first), Reverse (flip line order), or Shuffle (random).
- 3 Toggle Case-insensitive to ignore capitalisation when sorting, and Trim whitespace to strip leading/trailing spaces before comparing.
- 4 The result appears instantly in the Output panel. Copy it with the copy icon.
Frequently asked questions
Does it handle Unicode and non-English text?
Yes. Sorting uses the JavaScript localeCompare function, which correctly handles accented characters, CJK text, and other Unicode beyond ASCII.
What does "Trim whitespace" do exactly?
When checked, each line has its leading and trailing spaces (and tabs) stripped before sorting and output. This is useful when lines have inconsistent indentation or trailing spaces that would otherwise affect sort order.
Is the shuffle truly random?
The shuffle uses the Fisher-Yates algorithm with Math.random(), which is not cryptographically secure but is fine for practical shuffling tasks. For cryptographic randomness, use UUID or Password Generator instead.
Can it sort numbers correctly?
Alphabetical sort orders numbers lexicographically: 1, 10, 2, 20, 3. For correct numeric sorting, use the By length mode to sort by character count instead, or pad numbers with leading zeros before sorting.
Is there a line limit?
No explicit limit — it handles whatever the browser textarea can hold. Thousands of lines work fine.