Sorts multiple lines of text by ASCII code order, or by the numeric value at the start of each line, with both ascending and descending options
The Line Sorter rearranges multiple lines of text using either of two methods: sorting by ASCII code order, or sorting by the numeric value at the start of each line, with both ascending and descending options. Everything runs entirely in your browser, so your text never leaves your device.
Whether you need to tidy up an unordered list, naturally sort numbered rows, or quickly reorder code and log lines, this tool completes the job in milliseconds — a handy everyday utility for text cleanup.
In ASCII mode, each line is treated as a string and compared character by character using the charCodeAt value, which is equivalent to a lexicographic comparison in ASCII/UTF-16 byte order. Digits (48-57), uppercase letters (65-90) and lowercase letters (97-122) follow the ASCII table strictly, matching the default behavior of the Linux sort command.
In leading-number mode, the regular expression ^[-+]?\d+ extracts the leading digit sequence (including a sign) from each line, converts it to a number and compares numerically; lines without a leading number are grouped at the end. The comparator records each line's original index to guarantee stability, so lines with equal keys keep their relative order. Descending order is achieved by inverting the comparison result.
Input (unordered lines):
banana
Apple
cherry
123. Task three
1. Task one
2. Task two
After ASCII ascending sort:
123. Task three
1. Task one
2. Task two
Apple
banana
cherry
After leading-number ascending sort:
1. Task one
2. Task two
123. Task three
Apple
banana
cherry
The number parts are ordered by value (1 < 2 < 123), and lines without a leading number are placed at the end.
The Line Sorter belongs to the text-processing category, together with Text Diff and Word Counter, and works well in document cleanup workflows. To verify the code values of characters in your results, check ASCII Lookup; when dealing with multiline data that contains URL parameters, organize it first with URL Params to Table.
If you need to remove duplicate rows after sorting, use the Text Deduplicator to finish the cleanup.