How to Sort or Reverse Lines of Text
Line Sorting
When to Sort Lines
Alphabetize lists, order config entries, prepare diff-friendly file contents, or reverse line order for debugging. Choose Sort or Reverse in tool settings before running.
Real-World Examples
Alphabetize hostnames in an allowlist before committing to git
Reverse stack trace lines to read chronologically
Sort dependency names for stable lockfile comparisons
Common Mistakes
- Sorting numbered lists lexicographically — "10" sorts before "2"
- Expecting numeric sort — this tool uses alphabetical (locale) comparison
- Sorting before deduplicating when you want unique sorted output
Developer Tips
- Pad numbers (01, 02, 10) if you need lexicographic order to match numeric order
- Pair with Remove Duplicate Lines for clean sorted lists
- Use Reverse to flip execution order in step-by-step logs
Frequently asked questions
Is sorting case-sensitive?
Use the Case sensitivity setting in tool settings. Ignore case compares lines without regard to letter case; Case sensitive uses exact casing. Both modes use locale-aware string comparison in your browser.
What does Reverse do?
Reverse flips the line order from last to first without changing line content.
Are blank lines preserved?
Yes. Blank lines participate in sorting like any other line.