Sort Lines

Sort lines alphabetically, numerically, by length or reversed.

About Sort Lines

A sort lines tool puts lines of text in alphabetical, natural, numeric or length order, reverses or shuffles them, and can drop duplicates and trim spaces.

How to use

  1. Paste the lines. The sorted result appears as you type.
  2. Pick an order: Alphabetical, Natural, Numeric, Length, Shuffle or Reverse.
  3. Tick Descending, Case-sensitive, Remove duplicates or Trim lines as needed, then copy or download sorted.txt.

Options

  • Alphabetical compares characters using your locale, so accented letters sort next to their base letter. With Case-sensitive on, it uses plain character codes and uppercase comes first.
  • Natural compares digits inside text by value, so file2 comes before file10.
  • Numeric sorts by the number each line starts with (-3, 2.5, 10); lines with no leading number go last in their original order.
  • Length sorts shortest to longest; Reverse flips the current order; Shuffle randomises it.
  • Remove duplicates keeps the first copy of each line, ignoring case unless Case-sensitive is on. Trim lines strips leading and trailing spaces first.

Example

file10.txt
file2.txt
File1.txt
→ Natural:  File1.txt, file2.txt, file10.txt
→ Alphabetical: file10.txt, File1.txt, file2.txt

Privacy

The text is sorted in the browser. No request is made, and nothing is stored.

Frequently asked questions

How do I sort lines alphabetically?
Paste the text, keep the Alphabetical order and copy the result. Each line is compared from its first character; tick Descending for Z to A.
What is natural sort order?
An order where runs of digits are compared as numbers rather than character by character, so "item 2" comes before "item 10". Plain alphabetical order puts "item 10" first because the character 1 is lower than 2.
Why do capital letters sort before lowercase?
In ASCII and Unicode, A to Z are codes 65 to 90 and a to z are 97 to 122, so a byte-wise sort puts every capital first. Turn off Case-sensitive to compare letters regardless of case.
How do I sort lines and remove duplicates at the same time?
Tick "Remove duplicates" with any order. The first copy of each line is kept and the rest are dropped before sorting, like running sort -u on the command line.