Skip to content

Sort Lines

Sort text alphabetically, numerically, by length or at random.

LOCAL WORKSPACENO UPLOAD REQUIRED

Sorted lines

Paste some lines on the left.

About Sort Lines

Sorting a list is the fastest way to spot gaps, duplicates and outliers. Doing it in a spreadsheet means importing and exporting; doing it in an editor means remembering the right command.

This tool sorts pasted text alphabetically, numerically, by line length or randomly, in ascending or descending order, with case sensitivity and natural number handling as options.

How Sort Lines works in your browser

Lines can be sorted alphabetically, numerically, by length or randomly, ascending or descending. Alphabetical sorting uses Intl.Collator, and natural mode compares embedded numbers by value so item2 comes before item10.

The sort is stable — lines that compare as equal keep their original order — and blank lines can be removed or grouped at the end.

When to use it

  • Alphabetising a list of names or keywords.
  • Ordering file names that contain numbers correctly.
  • Shuffling a list to pick items in random order.

Worked examples

Put numbered filenames in human order

Settings: Natural (item2 < item10), Ascending

Input

report10.csv
report2.csv
report1.csv

Expected output

report1.csv
report2.csv
report10.csv

Natural mode compares embedded digit sequences numerically. Use it for exported filenames or numbered tasks. Alphabetical mode instead compares text and can place report10 before report2.

Sort quantities by their leading number

Settings: Numeric, Ascending

Input

12 kg
2 kg
unknown
-3 kg

Expected output

-3 kg
2 kg
12 kg
unknown

Numeric mode reads the number at the beginning of each line with parseFloat. It leaves the original line intact and puts lines without a finite leading number after numeric entries.

Limits and checks before you use the result

  • Sorting operates on whole lines, not CSV columns. Export just the field you need or use a spreadsheet for multi-column records.
  • Alphabetical and natural order follow your browser locale. Numeric mode does not interpret decimal commas, currency prefixes or convert units. For example, 1,200 is read as 1, not 1200.
  • Keep a copy of the original. Random mode changes order without a reproducible seed; use Remove Duplicate Lines separately if you want to deduplicate.

Frequently asked questions

What is natural sorting?

It compares embedded numbers by value, so item2 sorts before item10 instead of after it.

How are blank lines handled?

Remove blank lines is enabled initially. Turn it off to keep them; their position depends on the selected sorting mode and direction.

Is the sort stable?

Yes. Lines that compare as equal keep their original relative order.

Related tools