Sort Lines

Sort lines alphabetically or numerically.

Open tool

Overview

Sort the lines of any text — alphabetically (ascending or descending), numerically, by length, or randomly shuffled. Options include case-sensitive vs case-insensitive comparison, trimming whitespace before sorting, and handling of natural-number sequences ("file2" before "file10" rather than after).

Developers cleaning up import statements, sysadmins ordering log entries, writers alphabetizing reference lists, and analysts sorting CSV rows by a single column all reach for it. It pairs well with Duplicate Line Remover for producing a clean unique sorted list.

How it works

The tool splits your input on line breaks, applies the chosen comparison function to the array of lines, and joins the result back with the same line ending. Natural sort mode parses embedded digit runs as numbers so the ordering matches what humans expect — useful when filenames or version strings are mixed in. Locale-aware sorting respects accents and language-specific rules.

Examples

Input:           Output (ascending alpha):
  cherry           apple
  apple            banana
  banana           cherry
Input:           Output (numeric):
  100              5
  5                42
  42               100
Input:           Output (natural):
  file10           file2
  file2            file10       ← natural sort
  file1            file1

FAQ

What's "natural sort"?

Natural sort treats embedded numbers as numbers, so "file2" comes before "file10". Plain alphabetical sort puts "file10" before "file2" because '1' < '2' character-wise.

Does it preserve original line endings?

Yes. The tool detects the dominant line ending in your input (LF, CRLF) and uses the same in the output.

Can I sort by a specific column?

Basic column sorting is supported in some modes — split each line on a separator and sort by a chosen column index. For complex multi-key sorting, a spreadsheet or proper data tool will work better.

Try Sort Lines

An unhandled error has occurred. Reload ×