Sort lines

What is a Sort Lines?

Sorting lines is a constant small task: alphabetising a list of names, ordering imports, sorting log entries, arranging keywords or tidying configuration. This tool sorts any line-based text several ways, with options to clean it up at the same time.

How to use it

  1. Paste the text with one item per line.
  2. Choose the sort method and options.
  3. Copy the sorted result.

Sort methods

  • Alphabetical: standard A to Z order.
  • Natural: treats numbers inside text as numbers, so file2 comes before file10.
  • Numeric: sorts by numeric value, so 9 comes before 10 and 100.
  • By length: shortest to longest line.
  • Random: shuffles the order.

Example: alphabetical vs natural vs numeric

Input lines: item10, item2, item1.

  • Alphabetical: item1, item10, item2, because the character 1 comes before 2.
  • Natural: item1, item2, item10.

For pure numbers 100, 25, 3: alphabetical gives 100, 25, 3; numeric gives 3, 25, 100.

Options

  • Ignore case: otherwise uppercase letters sort before lowercase in ASCII order.
  • Trim: leading spaces would otherwise push lines to the top.
  • Remove duplicates and reverse order.

Command-line equivalents

  • sort file.txt, sort -n for numeric, sort -V for natural version order, sort -r to reverse, sort -u to deduplicate.
  • Note that sort results depend on the locale; set LC_ALL=C for byte order.

Frequently Asked Questions

What is natural sort order?

A sort that compares numbers inside text by value, so file2 comes before file10.

Why are uppercase lines sorted first?

In character code order, uppercase letters come before lowercase. Enable ignore case for dictionary-style sorting.

How do I sort numbers correctly?

Use numeric sorting. Alphabetical sorting puts 100 before 25 because it compares characters.

Can I sort and remove duplicates at once?

Yes. Enable the remove duplicates option together with any sort method.