Skip to contentSkip to the inputSkip to the result

Sort text lines

Order names or lists alphabetically.

Loading tool

Instructions

Sort text lines

How to use

  1. Paste one entry per line and choose an order: A–Z, Z–A, by length, by number, or the original order reversed.

Supported input

  • Locale-aware ordering with natural numbers.
  • Tab- or comma-separated lines can be sorted by one cell.

Input example

pear / apple

Result example

apple / pear

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • Order names or lists alphabetically.

Alphabetical, natural and numeric order are three different sorts

Pick the order you actually need

  • Names, client lists or vocabulary in dictionary order: ascending.
  • Numbered file names such as photo1 … photo12, or versions such as v1.9 and v1.10: ascending, which compares digit runs as numbers.
  • Prices, scores or populations with decimals, minus signs or thousands separators: by number value.
  • A table pasted from a spreadsheet, sorted on a score rather than the name: set the sort column to the second, third or fourth cell.
  • A log written oldest first that you want newest first: reverse the order.

Language-aware comparison

Ascending order compares lines with the browser’s Intl.Collator, set to Korean with numeric comparison. That collator implements the Unicode Collation Algorithm (UTS #10) with CLDR data, so letters are not ranked by their code numbers. A plain code-point sort puts Banana before apple, because capital B is 66 and small a is 97; here the result is apple, Banana, zebra.

Korean syllables fall in dictionary order, initial consonant first: entering 힣, 가, 까, 나 and the bare letter ㄱ gives ㄱ, 가, 까, 나, 힣, with the doubled consonant 까 right after 가.

Where natural sorting goes wrong: decimals

Numeric collation treats every run of digits as a whole number. That is right for v1.2.3, v1.2.10, v1.9, v1.10, which come out in that order, but it reads the digits after a decimal point as a whole number too, so 1.5 sorts before 1.25 (5 is less than 25). Minus signs and thousands separators are not read as part of the number either.

By number value reads the value at the start of each line as a real number, including a sign, a decimal point, thousands separators and exponents such as 2e3. The lines 1,200 won, -3, 1.5, 10, 1.25, memo, 2e3 come out as -3, 1.25, 1.5, 10, 1,200 won, 2e3, memo, with lines that do not start with a number at the end. Sorted ascending instead, the same list comes out as -3, 1,200 won, 1.5, 1.25, 2e3, 10, memo, which has nothing to do with size.

Worked example: a score table

  1. 1Copy two columns from a spreadsheet and paste them; the cells are separated by tabs: Kim 82, Lee 95, Park 78, Choi 95.
  2. 2Sort column 2, by number value: Park 78, Kim 82, then the two 95s. Ties are broken by comparing the whole line, so Choi comes before Lee.
  3. 3For the highest score first, choose descending: the 95s, then Kim 82, then Park 78, with the tie order reversed as well. That works for whole-number scores; with decimals or negatives, sort by number value and then apply Reverse the order.
  4. 4When no line contains a tab, commas separate the cells, so CSV lines such as “London,8866180” sort the same way.

Mixed scripts and blank lines

  • By default lines starting with Korean come first and everything else, digits and Latin letters, follows. Choose Latin first to swap the two groups.
  • Descending keeps those groups in place and reverses the order inside each one.
  • Blank lines always go to the end, whatever the order, and Reverse the order turns over only the lines with content.
  • Duplicate lines are kept; remove them first with the duplicate-line tool if each item should appear once.

Checked

Frequently asked questions

How do I get file1, file3, file12 in number order?

The tool uses natural sorting, which compares numbers by value, so it gives file1, file3, file12. A plain character sort would put file12 before file3.

Which comes first when Korean and English lines are mixed?

Lines starting with Korean come first by default; you can switch to Latin first. English is not split by case, so Apple comes before banana.

Can I sort by length?

Yes. Choose Shortest first or Longest first; lines of equal length are then sorted alphabetically. Reverse the order turns the list over without sorting. For lines split by tabs or commas, choose Sort by column to sort on the second to fourth cell; with By number value that sorts by a score column.