Sort text lines alphabetically, by length, numerically, or randomly.
Sort lines of text alphabetically, numerically, or by length — ascending or descending, case-sensitive or case-insensitive, with optional whitespace trimming. Also supports natural sort (so "file2" comes before "file10") and reverse-only mode for flipping line order without resorting. Everything runs locally in your browser; nothing is uploaded.
"Sort these lines alphabetically" sounds simple, but the order you get depends on choices most people make implicitly. Should "Apple" come before "banana" or after it? Does "10" come before "2" or after? Are leading spaces significant? What about accented characters — does "ñ" sort with "n" or after "z"?
This tool exposes the choices explicitly. The default — case-insensitive alphabetical with whitespace trimmed — handles 80% of real cases. The other modes handle the remaining 20% where the default produces surprising results.
Alphabetizing reference lists. Bibliographies, glossaries, ingredient lists, contact lists, file lists. Anything that's easier to scan in alphabetical order than in input order.
Sorting log entries by timestamp. Logs that contain ISO 8601 timestamps at the start of each line sort correctly with default alphabetical sort, since ISO timestamps are designed to sort lexicographically. Sort the log file to get strict chronological order.
Sorting filenames in natural order. A list of files like file1.txt, file2.txt, file10.txt, file20.txt sorts lexicographically as file1, file10, file2, file20 — wrong for almost every human-readable purpose. Natural sort gets the order most people expect: file1, file2, file10, file20.
Diff preparation. Comparing two unordered lists with a diff tool produces noise unless both lists are sorted first. Sort both, then diff — the differences become much easier to spot.
Email and contact list alphabetization. Address books, attendee lists, recipient groups. Sort case-insensitively (so "Smith" and "smith" group together) with whitespace trimmed (so trailing spaces don't sort separately).
Sorting CSV column values. Extract a single column from a CSV (often via copy-paste from a spreadsheet), sort it, see distinct values and the order they appear in. Useful for data exploration.
Removing visual chaos from copy-pasted text. Lists assembled from multiple sources have arbitrary internal order. Sorting imposes structure that makes the list reviewable.
Sorting by line length. When auditing for verbose entries that need editing down, or for short entries that need expanding, sort by length and scan the extremes. Useful in editorial work.
Alphabetical, ascending (the default) — A to Z, case-insensitive by default. Locale-aware so accented characters sort with their base letter.
Alphabetical, descending — Z to A. Same locale handling.
Numerical, ascending and descending — for lines that begin with numbers. 10 sorts after 9 (which it doesn't in alphabetical mode). Lines that don't start with a number sort to the end.
Natural sort, ascending and descending — alphabetical sort that recognizes embedded numbers. file2 sorts before file10, while alphabetical mode would put file10 before file2. Use this for filenames, version numbers, and any list with mixed alphabetic and numeric components.
By length, ascending and descending — sort by character count of each line, shortest first or longest first. Tie-breaking falls back to alphabetical.
Reverse only — flip the line order without sorting. The first line becomes the last; line order is fully reversed but no sorting occurs. Useful when input is already in the order you want and you just need it backwards.
Case-insensitive sorting (the default) treats "apple" and "Apple" as equivalent for sort comparison. This produces output that looks "normal" to most people: capitalized words don't bunch at the top.
Case-sensitive sorting (the toggle) puts all uppercase letters before all lowercase letters in ASCII order. "Banana" comes before "apple" because uppercase B (66) is less than lowercase a (97). This is mostly useful for code and identifiers where case carries meaning, and for matching the sort order produced by Unix tools that use byte-order sort.
Sorting numbers as strings. If your list is "1, 2, 10, 20, 100" and you use alphabetical sort, the output is "1, 10, 100, 2, 20" — almost certainly not what you want. Use numerical mode for pure numbers, natural mode for mixed alphanumeric.
Whitespace before content. A line that starts with a space sorts before everything else in case-sensitive mode (space is character 32, all letters are 65+). The default whitespace-trim option fixes this. If your sort produces a few lines mysteriously bunched at the top, check for leading whitespace.
BOM and other invisible characters at line start. Same problem as whitespace. The trim option doesn't catch these by default. If you suspect invisible characters, paste the input into the Character Counter to confirm.
Mixing locales. Accented character sorting depends on locale. Spanish, German, Swedish, and Hungarian each have specific rules about where letters like ñ, ä, ø, and á appear in the alphabet. This tool uses your browser's default locale via JavaScript's Intl.Collator, which follows your system's language setting. For specific locale needs, sort externally with a tool that lets you pick the locale.
Confusing sort with deduplication. Sorting groups identical lines together but doesn't remove duplicates. To dedupe, sort, then run the output through Remove Duplicates (or use Remove Duplicates first — its case-sensitivity options work the same way).
This tool — fastest for plain-text line lists in a browser, exposes natural sort and length sort as explicit options, no install, locally executed.
The sort command — the gold standard for sorting on Unix systems. Handles GBs of data, integrates with pipelines, supports locale, numerical, and natural-sort flags. Best for large files and scripted workflows. Default is byte-order; sort -f for case-insensitive, sort -n for numerical, sort -V for version-style natural sort.
Spreadsheet sort (Excel, Google Sheets, Numbers) — best when the data is already in a spreadsheet and the sort needs to respect column structure. The "Sort by" dialog lets you specify sort key, direction, and case sensitivity. Painful for free-form line text; pasting into a spreadsheet just to sort is overkill.
The tool splits input on line breaks, applies the chosen sort comparator (alphabetical, numerical, natural, length, or reverse), and rejoins with newlines. Comparators use JavaScript's Intl.Collator for locale-aware string comparison and localeCompare with numeric: true option for natural sort.
Sort is stable — items that compare equal preserve their input order. Performance is O(n log n), which handles millions of lines in under a second on typical hardware.
Sort before deduplicating. Sorted input makes deduplication output cleaner — duplicates appear adjacent, which means tools and humans both spot them faster. The Remove Duplicates tool handles unsorted input fine, but sorted is easier to reason about.
Default to natural sort for filenames and versions. The friction of "version 10 before version 2" sneaks into surprisingly many real workflows. Natural sort fixes it once.
Use reverse-only after another sort. If you've sorted ascending and want descending, the reverse-only mode is faster than re-sorting. This matters when the sort is expensive or when you want to see "ascending and descending side by side" without paying twice.
Alphabetical sort treats numbers character-by-character: "10" comes before "2" because "1" comes before "2". Natural sort treats embedded numbers as numbers: "2" comes before "10" because 2 is less than 10. For filenames, version numbers, or any list with embedded numerals, natural sort matches human expectation.
Mostly yes. The tool uses the browser's Intl.Collator, which handles Latin-script accented characters, Cyrillic, Greek, and Han characters per Unicode collation rules. Specific locale-dependent edge cases (where exactly does "ø" sort in Danish vs in English?) follow the browser's default locale.
No. Sort groups duplicates together but doesn't remove them. Use Remove Duplicates either before or after sorting if you need uniqueness.
Yes. Empty lines are treated as lines with empty content; they sort to the start of the output (case-sensitive mode) or are grouped together based on locale (case-insensitive mode).
Not directly. The tool sorts by the entire line content. For column-aware sorting, paste into a spreadsheet, sort by column, then copy back.
With trim enabled (default), they're treated as identical for comparison purposes. Stable sort then preserves their input order. With trim disabled, they sort separately based on the trailing whitespace differences.