← Back to BlogText Tools

How to Sort Text Lines Alphabetically or in Reverse Order

September 6, 2026

Written by Mohammad Sohail

Sorting lines alphabetically is a deceptively common task. Organizing a list of names, sorting inventory items, arranging command-line output, ordering database entries — these all require line sorting. Doing it manually in a text editor is tedious and error-prone.

When Line Sorting Is Useful: Alphabetizing a list of contacts or customers. Sorting filenames for batch processing. Organizing command-line output (like ls -la or netstat). Arranging inventory items, SKUs, or product names. Sorting IP addresses or log entries. Reversing the order of lines in a file.

What I Tested: I used the [Sort Lines](/text-tools/sort-lines) with several text inputs.

Input: 'banana\napple\ncherry\ndate'. Sorted A-Z: 'apple\nbanana\ncherry\ndate'. Correct alphabetical order.

Input: 'banana\napple\ncherry\ndate'. Sorted Z-A (reverse): 'date\ncherry\nbanana\napple'. Correct reverse order.

Input: 'Charlie\nalice\nBob\nDiana'. Sorted A-Z: 'alice\nBob\nCharlie\nDiana'. Correct — uppercase letters sort before lowercase in ASCII order.

Input: '3. Apple\n1. Banana\n2. Cherry'. Sorted A-Z: '1. Banana\n2. Cherry\n3. Apple'. Correct — sorted by the full line including numbers.

Step-by-Step: (1) Open the [Sort Lines](/text-tools/sort-lines). (2) Paste your text with one item per line. (3) Click 'Sort A-Z' for ascending order or 'Sort Z-A' for reverse order. (4) Copy the sorted result.

One Limitation: The sort is case-sensitive by default. 'apple' comes before 'Banana' because lowercase letters have higher ASCII values than uppercase. If you need case-insensitive sorting, convert all text to lowercase first using the [Case Converter](/text-tools/case-converter), then sort.

Common Mistake: Sorting numbered lists without considering numeric order. '10. Item' sorts before '2. Item' because '1' < '2' in ASCII. The tool sorts by character, not by numeric value. For numeric sorting, pad numbers with leading zeros (01, 02, ..., 10) before sorting.

Privacy: Your text is processed entirely in your browser. It is never sent to any server.

Next Step: After sorting, if you have duplicate lines, use the [Remove Duplicate Lines](/text-tools/remove-duplicate-lines) tool to clean them up.