๐Ÿ”ค Text Line Sorter

Sort a block of multi-line text alphabetically (ascending or descending) or numerically. Also supports case-insensitive sorting and removing duplicate lines at the same time. Handy for organizing lists or prepping data.

How to use

  1. Enter the text you want to sort, one item per line.
  2. Choose the sort order (ascending or descending) and any options โ€” case-insensitive, remove duplicates, numeric sort.
  3. The sorted result appears automatically. Use the "Copy" button to copy it.

How the calculation works

This tool splits the input into lines and sorts each line as one item. Normal sorting uses the browser's localeCompare, which compares text in dictionary order for the language rather than by raw character codes. As a result, "apple" and "Apple" sit next to each other, and Japanese hiragana and katakana are interleaved by reading. Kanji are grouped after kana and are not sorted by pronunciation. With "Sort numerically" on, the start of each line is read as a number with parseFloat and lines are ordered by value. As plain text, "10" sorts before "2"; compared as numbers, the order becomes 2 โ†’ 10. Lines that cannot be read as a number are placed after the numeric lines, in dictionary order. "Remove duplicates" runs before sorting and keeps only the first occurrence of each line. Descending order is simply the ascending result reversed.

Worked example

Input banana Apple cherry apple Ascending (normal) apple Apple banana cherry Sort numerically (input: 10 apples / 1,000 / 2 / -5 / 3.5) -5 1,000 2 3.5 10 apples "1,000" is read only up to the comma, so it counts as 1 and comes before 2. For "10 apples", the leading 10 is used.

Things to be aware of

  • Numbers with thousands separators (such as 1,000) are read only up to the comma. Remove the commas first if you need them sorted correctly.
  • Empty lines count as items and appear at the top in ascending order. Remove them with the whitespace remover first if you do not want them.
  • In numeric mode, descending order reverses the whole ascending result, so lines that are not numbers come first.
  • Kanji are compared by character rather than by reading, so this is not suitable for sorting Japanese names in gojลซon order. Add a column with the reading and sort by that instead.

FAQ

Can lines containing numbers be sorted numerically?

Yes โ€” turn on "Sort numerically" to interpret each line as a number and sort by value (non-numeric lines may not sort as expected).

Does this sort non-English text correctly?

Yes โ€” it uses the browser's standard string comparison, so it sorts other languages in a reasonable locale-aware order too.

Can I remove duplicates while sorting?

Yes โ€” turn on "Remove duplicates" to strip out repeated lines (any occurrence after the first) at the same time as sorting.