Sort Lines of Text Online — Alphabetical or Reverse
Sort lines of text alphabetically or in reverse order online. Case-sensitive option. Free, browser-based.
Sorting lines of text alphabetically is useful for organising lists, normalising configuration files, sorting word lists, and preparing data for comparison. This tool sorts lines in ascending (A→Z) or descending (Z→A) order, with options for case-sensitive comparison and whitespace trimming. Empty lines are moved to the end of the output.
How to use
- Paste the text with lines you want to sort into the input textarea.
- Choose the sort direction (A→Z or Z→A) and options, then click 'Sort Lines'.
- The sorted text appears in the output. Copy or download as needed.
FAQ
What sort algorithm is used?
The tool uses JavaScript's built-in Array.sort() with a locale-aware comparison function (localeCompare). This produces correct alphabetical ordering for English and most European languages, handling accented characters (é, ü, ñ) in the expected alphabetical position rather than sorting them after 'z'.
How are numbers sorted?
Lines are sorted lexicographically (as text strings) by default. This means '10' sorts before '2' because '1' comes before '2' in string comparison. For numerically correct sorting of number lists, reorder the numbers to have consistent zero-padding (e.g., '02', '10') before sorting, or use a spreadsheet application that offers numeric sort.
What does 'case-sensitive' sorting mean?
With case-sensitive sorting enabled, uppercase letters sort before lowercase letters in ASCII order (A, B, C ... Z, a, b, c). With case-sensitive disabled (the default), upper and lowercase versions of the same letter sort together, giving the natural dictionary order (a, Apple, banana, Banana).
Are empty lines preserved or removed?
Empty lines are preserved but sorted to the end of the output. If 'Trim whitespace' is enabled, lines that consist only of spaces or tabs are treated as empty lines and also sorted to the end. This keeps the data lines together at the top of the output.
Can I sort a list of file paths or URLs?
Yes. File paths and URLs are just strings and will be sorted alphabetically. This can be useful for normalising import lists in code files or organising URL lists. For file paths, the sort is by the full path string, so '/assets/a.js' sorts before '/components/a.js'.
Is my text sent to a server?
No. All sorting runs entirely in your browser using pure JavaScript. No data is sent to any server.