Skip to content

Sort Lines

Order any list one item per line: A to Z, Z to A, natural, numeric or by length.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is Sort Lines?

Sorting lines is a daily chore for lists of names, imports, CSS classes, file names and log entries. This tool offers eight orders: alphabetical and reverse, natural order (file2 before file10), by the number found in each line (ascending or descending) and by length.

By default the comparison is exact and predictable (code-unit order: capitals before lowercase). Turn on "ignore case" for a friendlier list, or "language-aware order" to use localeCompare so accented letters such as É sit next to E. You can also drop duplicates and empty lines in the same pass.

How does it work?

  1. Paste your lines, one per line.
  2. Pick the order: A → Z, Z → A, natural, numeric, or by length.
  3. Adjust ignore-case, language-aware order, unique and remove-empty, then copy the sorted list.

Common use cases

  • Alphabetizing a list of names, tags or imports.
  • Sorting file names such as img1.png … img12.png the way a person expects.
  • Ranking lines that start with a number, such as "42 errors" or prices.
  • Ordering CSS classes or config keys so diffs stay small.

Examples

Try this input in the tool above:

Input
file10.txt
file2.txt
Banana
apple
file1.txt
cherry
Éclair
Output
apple
Banana
cherry
file1.txt
file2.txt
file10.txt
Éclair

Privacy

Sort Lines runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Numeric order uses the first number found in each line; lines without a number go last. Language-aware order depends on the collation data of your browser.

Frequently asked questions

Why do capital letters come first?

The default compares raw character codes, where all capitals precede lowercase letters. Enable "ignore case" or "language-aware order" for dictionary order.

What is natural sort?

Natural sort compares digit sequences by value, so "file2" comes before "file10" instead of after "file1".

More tools in Text Tools →