🔧Toolify

Text Sorter — Sort Lines Online (A–Z, Z–A, Deduplicate)

Sort lines of text alphabetically or in reverse order, with optional case-insensitive matching, duplicate removal, empty-line stripping, and whitespace trimming. Everything runs in your browser — no data is sent to a server.

Sorted output
 
1 lines

How it works

How text sorting works

Sorting splits your text into individual lines, orders them lexicographically, and joins them back together. Lexicographic order is the same principle used in dictionaries: characters are compared one at a time from left to right using their Unicode code points.

By default this tool uses case-insensitive comparison, which means 'apple', 'Apple', and 'APPLE' are treated as identical for ordering purposes. Enable case-sensitive mode when you need uppercase letters to sort before lowercase (e.g., 'Z' before 'a' in ASCII order).

Common use cases

Alphabetizing name lists, tag clouds, or CSV column values are the most common tasks. Developers frequently sort import statements or configuration keys to make code reviews easier and diff outputs cleaner.

Data analysts use line sorting to quickly spot duplicate entries in exported lists or to align two datasets before a manual comparison. The duplicate-removal option condenses a list with thousands of entries to only unique values in one click.

Sorting algorithms: what happens under the hood

Modern JavaScript engines use an optimized variant of TimSort (a hybrid of merge sort and insertion sort) for the Array.prototype.sort method. TimSort is stable, meaning lines that compare as equal preserve their original relative order — useful when you sort a deduplicated list and want consistent behavior.

For the vast majority of text lists you will encounter, the algorithm finishes in well under a millisecond in the browser, even for tens of thousands of lines. If you need locale-aware sorting (e.g., accented characters in French or German sorted correctly), consider using Intl.Collator in your own code, as this tool uses simple Unicode code-point comparison for maximum speed.

Frequently asked questions

Does sorting happen automatically?

Yes. The output updates in real time as you type or change any option — there is no submit button.

Is sorting case-sensitive by default?

No. By default the tool sorts case-insensitively so that 'Apple' and 'apple' sort together. Enable the 'Case-sensitive' checkbox to use raw Unicode code-point order instead.

What counts as a line?

Each newline character (\n) marks the end of a line. If you paste text from a spreadsheet or from Windows (\r\n line endings), the tool handles it correctly and sorts by logical lines.

Can I sort numbers?

The tool sorts lexicographically, not numerically. That means '10' sorts before '9' because '1' < '9'. For numeric sorting, pad numbers with leading zeros (e.g., '09' vs '10') before pasting.

What does 'Remove duplicates' do exactly?

It keeps the first occurrence of each unique line and discards subsequent identical ones. The comparison respects your case-sensitivity setting, so 'Apple' and 'apple' are treated as the same line only in case-insensitive mode.

Does my data leave my browser?

No. All processing happens locally in JavaScript. Nothing is uploaded to any server.

Is there a line limit?

There is no hard limit enforced by this tool. Performance depends on your device, but modern browsers handle hundreds of thousands of lines without noticeable lag.

How do I sort a CSV column?

Copy the column values from your spreadsheet application into the input area (they paste as one value per line), apply your options, copy the sorted output, and paste it back. Then re-attach your other columns manually or in a spreadsheet formula.

Related tools

Last updated:

Try our AI prompts →