Sort Lines
Sort lines alphabetically, ascending or descending, with optional case-insensitive comparison.
Runs in your browser — files never leave your device
How it works
Paste any list — one item per line — and it is sorted instantly as you type. Pick A → Z for ascending or Z → A for descending, and use the two checkboxes to control the comparison: Ignore case compares lowercased copies while the output keeps each line’s original casing, and Trim lines strips leading and trailing whitespace first. The Copy button grabs the whole sorted list.
The ordering is lexicographic: lines are compared character by character using Unicode character codes. Two consequences follow. Digits compare as characters, not values — 10 sorts before 2 because the comparison stops at the first differing character. And every uppercase letter has a smaller code than every lowercase letter, so a case-sensitive A → Z puts Banana before apple. The sort is also stable: lines that compare equal stay in the order you pasted them.
A concrete example: sorting the four lines 10, 2, apple, Banana in A → Z order returns 10, 2, Banana, apple. Tick Ignore case and it becomes 10, 2, apple, Banana — the words now compare by their lowercased forms. The digit ordering stays the same either way; zero-padding to 02 and 10 is the standard fix when you need numeric order.
Typical jobs: alphabetizing import statements and dependency lists, ordering keys in .env and config files, tidying keyword or email lists before deduplication, sorting a column of names pulled from a CSV, and normalizing log output so two runs can be diffed line by line. Sorting also groups identical lines next to each other, which makes duplicates easy to spot before you remove them.
Two gotchas worth knowing. The comparison is not locale-aware — accented characters have higher character codes, so they sort after the plain a–z alphabet rather than next to their base letter. And Trim lines changes the output, not just the comparison: lines are emitted trimmed. Mixed line endings are no problem — CRLF, CR and LF input all split correctly, and the output joins lines with LF.
Frequently asked questions
- Is the sort numeric or alphabetical?
- Alphabetical only — lines are compared character by character, so 10 sorts before 2 because the comparison never gets past the 1, and 100 sorts before 25 for the same reason. If you need numeric order, zero-pad the numbers to the same width first: 002, 010, 100 sorts correctly.
- Why do capitalized lines sort before lowercase ones?
- The case-sensitive comparison uses raw character codes, and every uppercase letter (A–Z, codes 65–90) is smaller than every lowercase letter (a–z, codes 97–122). That is why Zebra lands before apple in A → Z order. Tick Ignore case to compare lowercased copies and get dictionary-style ordering instead.
- Is the sort stable?
- Yes. Lines that compare as equal keep their original relative order, as JavaScript guarantees for its built-in sort. With Ignore case on, APPLE, apple and Apple all compare equal, so they come out in exactly the order you pasted them.
- What does Trim lines do?
- It strips leading and trailing whitespace from every line before comparing, and the trimmed lines are what appears in the output. Without it, an indented line sorts by its leading spaces — the space character (code 32) is smaller than every letter and digit, so indented lines float to the top.
- Where do blank lines end up?
- An empty line compares lower than any non-empty line, so blanks collect at the top in A → Z order and at the bottom in Z → A. They are never deleted — pair this tool with Remove Duplicate Lines if you want repeated blanks collapsed to one.
- Does it handle Windows and Unix line endings?
- Yes — input is split on CRLF, CR or LF, so text pasted from Windows, classic Mac or Unix sources all sorts correctly. The output always joins lines with LF newlines.
- Is my text uploaded?
- No. Sorting runs entirely in your browser as you type — nothing is sent to a server, and the same logic powers the ZoolTools mobile app via shared test vectors.
Related tools
- Word & Character CounterCount words, characters, sentences, paragraphs and lines instantly. Runs entirely in your browser — your text never leaves your device.
- Case ConverterConvert text between UPPERCASE, lowercase, Title Case, camelCase, snake_case, kebab-case and more — instantly in your browser.
- Slug GeneratorTurn any title into a clean, URL-friendly slug. Removes accents and punctuation; runs in your browser.
- Text ReverserReverse any string character by character. Handles Unicode correctly; runs locally.
- Remove Duplicate LinesStrip duplicate lines from a list, keeping the first occurrence. Optional case-insensitive and trim modes.
- Number Base ConverterConvert numbers between binary, octal, decimal and hexadecimal (or any base 2–36).