Skip to content
UniKit

Text sort

Sort lines alphabetically, naturally (a2 before a10) or by length, with reverse order, dedupe, case-insensitive matching, column and numeric sorting, plus dedicated handling for comments and blank lines.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Text to sort

Sort options

Sorted output

Lines are joined with LF, ready to paste back into a file.

Paste multi-line text to see the sorted result instantly.

What this tool does

  • Sort an exported ID list, a list of file names or a block of log lines before pasting it back into a file or spreadsheet.
  • Fix the classic “a10 before a2” problem: natural order compares digit runs by value, so v1.9 lands before v1.10.
  • Reorder CSV or TSV rows by the second or third column, optionally comparing that column as numbers so 10 no longer sorts before 2.
  • Clean up a pasted list: drop blank lines, remove duplicates, sort case-insensitively while keeping # comments pinned in their original order.

Example

Input

banana
apple10
apple2
apple1

Output

apple1
apple2
apple10
banana

Natural order is the default, so apple2 comes before apple10. Switch to alphabetical and you get apple1, apple10, apple2 instead.

Frequently asked questions

What is the difference between natural and alphabetical order?

Alphabetical order compares character by character, so apple10 comes before apple2 because the character 1 is smaller than 2. Natural order treats each run of digits as a number, putting apple2 before apple10 and v1.9 before v1.10. Both are compared by Unicode code point, so the result never depends on the system locale.

How are comments and blank lines handled?

Lines starting with # are treated as comments: they are not sorted and stay on top in their original order. Blank lines are dropped by default. Turn off “Pin comments on top” to sort comments like ordinary lines, and turn off “Drop blank lines” to keep them at the end of the result.

How do I sort by a specific column?

Set the sort key column to 1, 2, 3 and so on (1-based). The delimiter defaults to a comma — write \t for a tab. A row without that column counts as an empty value and sorts first. Enable “Compare that column as numbers” to sort by numeric value, with non-numeric rows placed after the numbers.

Does dedupe work on whole lines or on the column?

It removes duplicates by the current sort key: sorting whole lines means two identical lines are duplicates, while sorting by a column means two rows with the same column value are. Dedupe runs after sorting, so the entry that survives is the first one in the sorted result.

Does this sort Chinese text correctly?

Chinese characters are ordered by Unicode code point, which is not the same as pinyin order and is rarely what you want for a Chinese name list. Ignoring case only affects Latin letters and never changes the relative order of CJK characters.

Keywords:text sortsort linesalphabetical ordernatural sortdedupe linessort by column文本排序行排序自然排序多行排序去重按列排序

Related tools