Sort Lines
Sort text lines alphabetically in ascending or descending order
Text sort lines tool. Sort lines alphabetically ascending (A-Z) or descending (Z-A). Handle case sensitivity, numeric sorting, and custom delimiters
Text sort lines tool. Sort lines alphabetically ascending (A-Z) or descending (Z-A). Handle case sensitivity, numeric sorting, and custom delimiters
Sorting lines transforms disorganized text into structured, searchable lists. This tool handles both ascending and descending sorts with configurable options:
Alphabetical sorting follows lexicographic ordering, which compares strings character by character from left to right using character codes. In ASCII and Unicode, uppercase letters (A-Z, codes 65-90) come before lowercase letters (a-z, codes 97-122), which means 'Zebra' sorts before 'apple' in a default case-sensitive sort. This is why case-insensitive sorting is often preferred for natural-language lists — it produces results that match human expectations. Numeric sorting presents another subtlety: pure lexicographic sorting treats '10' as coming before '2' because the character '1' has a lower code point than '2'. Natural sort algorithms solve this by detecting numeric sequences within strings and comparing them numerically rather than lexicographically, so 'File 2' correctly precedes 'File 10'. Locale-aware sorting adds further complexity: in Vietnamese, accented characters have specific sort positions; in Spanish, 'ñ' traditionally sorts after 'n'; in Swedish, 'å' comes after 'z'. Most online sorters use JavaScript's default localeCompare() method, which respects your browser's locale settings.
Sorted lines serve many purposes beyond organizing a grocery list. In data preparation, sorting is often the first step before deduplication — duplicate entries become adjacent when sorted, making them easy to identify and remove. For contact management, sorting names alphabetically enables quick lookup in address books and CRM systems. URL lists benefit from sorting when building sitemap indexes or link directories, where alphabetical organization aids navigation. Keyword lists sorted alphabetically help content planners identify gaps in topic coverage and ensure comprehensive keyword targeting. File path lists sorted alphabetically reveal directory structure patterns and help spot naming inconsistencies. Email lists sorted by domain (using a secondary sort key) group recipients by organization, useful for BCC distribution. Log analysis benefits from sorting timestamps chronologically to trace event sequences. Even code imports sorted alphabetically improve maintainability by making it easier to locate specific import statements in large files. The versatility of line sorting makes it one of the most frequently used text manipulation operations.
By default, uppercase letters sort before lowercase letters because of their ASCII/Unicode code points ('Z' comes before 'a'). Enable case-insensitive sorting to treat 'Apple' and 'apple' as equivalent for ordering purposes, which produces more natural-looking alphabetical results.
Default alphabetical sorting treats numbers as text, so 'Item 10' comes before 'Item 2' (because '1' < '2'). Enable numeric-aware or natural sorting if available, which detects numbers within strings and compares them numerically, producing the intuitive order: Item 1, Item 2, Item 10, Item 100.
This tool sorts entire lines as single units. For tabular data with multiple columns, you'd need to extract the column you want to sort by first, sort those lines, then recombine. For complex multi-column sorting, spreadsheet software or command-line tools like sort with -t (delimiter) and -k (key) flags are more appropriate.
Empty lines are treated as lines containing only whitespace and are sorted along with other lines. They typically cluster at the beginning (ascending) or end (descending) of the sorted output. If you want to remove empty lines before sorting, use our Remove Empty Lines tool first.
Yes. All sorting happens locally in your browser using JavaScript. Your text never leaves your device, is never transmitted to any server, and is never stored. Sorting completes instantly without any network communication.