Sort Lines

Sort a list of lines alphabetically or in natural numeric order, then copy the reordered text.

Text is processed locally in your browser and is not uploaded.

Lines sorted
3

How to use this tool

  1. Put each item on its own line.
  2. Select alphabetical or natural order and choose ascending or descending.
  3. Run Sort lines. Empty lines can be omitted with the separate option.

Understanding the output

Alphabetical order compares text using English collation rules. Natural sorting recognizes digit sequences, so item 2 can appear before item 10. Duplicate lines are retained because sorting changes order rather than the number of repeated records.

File names with embedded numbers

Natural ascending order changes item 10, item 2, item 1 into item 1, item 2, item 10. Alphabetical ordering may place item 10 before item 2 because it compares text rather than numerical magnitude.

Choose natural sorting for numbered labels

Names such as chapter 2 and chapter 12 contain numbers inside text. Natural ordering is useful for these labels because it keeps their numerical progression readable. It does not turn each line into a mathematical number, and it should not be used to order decimals, negative values, currency, or dates when their numeric meaning matters.

For a dataset that needs numeric analysis, use a spreadsheet or a tool that explicitly parses the relevant number or date field. This sorter treats the full line as the comparison value, including prefixes and surrounding text.

Keep the record boundary clear

A line sorter works well for labels, simple task lists, and one-value records. It is not a CSV row sorter: quoted CSV fields can contain newlines that belong inside one record. Sorting those lines independently would corrupt the structure. Similarly, paragraphs containing several lines should be treated as blocks in a text editor rather than separated into individual entries here.

Method and supported input

The tool normalizes line endings and sorts with Intl.Collator using the English locale. Natural mode enables numeric comparison of digit sequences.

  • One line represents one independent item.
  • English collation is appropriate for the list.

Limitations

  • This is not mathematical sorting of signed or decimal numbers.
  • Collation details can vary slightly with Unicode data in the browser.

Common questions

Does this remove repeated lines?

No. Repeated lines remain repeated. The separate deduplication tool handles that task.

Why is the order different from a code-point sort?

Locale collation considers human-language ordering rather than only Unicode character values.

Sources and further reading