Skip to content

Sort Lines

Sort lines of text alphabetically (A-Z or Z-A) with natural number order, by line length, or shuffle and reverse them.

Sort Lines tool

Loading...

Example

Input: 3 lines: item10, item2, item1 - Sort Order A-Z

Result: item1 / item2 / item10

Sorting is natural (number aware), so item2 comes before item10 instead of the plain character order item1, item10, item2.

  1. Paste or type the lines of text you want to sort into the input area.
  2. Select a sort order from the menu: A to Z, Z to A, Shortest First, Longest First, Shuffle, or Reverse Order.
  3. For alphabetical sorts, numbers inside lines are ordered naturally, so 2 comes before 10.
  4. Review the sorted output that appears instantly in the result area.
  5. Click the copy button to copy the sorted lines to your clipboard.

Sorting Lines Alphabetically, by Length or at Random

Sort Lines puts every line of your text in order. Choose A to Z, Z to A, shortest first, longest first, a random shuffle or a plain reverse, and the sorted list appears right away.

The alphabetical sorts are number-aware, which is often called natural sort. A plain computer sort compares text one character at a time. So "Item 10" lands before "Item 2", because 1 comes before 2. This tool reads the whole number instead, which gives you Item 1, Item 2, Item 10. Sorting follows the language rules of your browser. Accented letters such as é sit next to e rather than after z, and capital and small letters are sorted together.

The length sorts count characters, spaces included. Lines of equal length keep their original order. Shuffle uses the Fisher-Yates method, which gives every possible order the same chance. That makes it fair for a running order or a quiz. Reverse simply flips the list upside down without sorting, so the last line becomes the first.

Sort Lines keeps repeated lines and blank lines, and blank lines go to the top in A to Z order. To keep each line only once, run the text through Remove Duplicate Lines first. To turn the sorted result into a comma-separated or numbered list, use the List Converter.

Frequently Asked Questions

Put one number on each line and choose A to Z. Whole numbers sort by value, so 5, 20 and 100 come out in that order. Choose Z to A for largest first. Decimals and negative numbers can sort wrongly, because each run of digits is compared on its own: 1.5 lands before 1.25, and -3 before -10.
Z to A sorts the lines alphabetically, starting from Z. Reverse Order does not sort at all. It just flips your list, so the last line becomes the first and the first becomes the last. Use Reverse Order to undo a list that was entered newest first, or to flip a ranking.
It is random enough for everyday use, such as mixing quiz questions, picking a speaking order or randomizing a playlist. The shuffle uses the Fisher-Yates method with the standard random numbers of your browser. Those numbers are not suitable for security or for a prize draw with legal rules. Each click gives a new order.
No. Each line is compared as a whole, starting from its first character. To sort names by surname, put the surname first, sort, and then swap the words back with a regex find and replace. To sort a CSV file by one of its columns, open it in a spreadsheet instead.

Related Tools

Remove Duplicate Lines

Remove duplicate lines from text while keeping the original order. Supports case-sensitive and case-insensitive modes.

Text and Writing

Word Counter and Character Counter

Count words, characters, sentences, and paragraphs in your text. Includes reading time and speaking time estimates.

Text and Writing

Find and Replace

Find and replace text with regular expressions, capture groups, case-sensitive matching, and a live match count.

Text and Writing

Whitespace Remover and Trimmer

Remove extra whitespace, trim leading and trailing spaces, collapse multiple spaces, and clean up messy text formatting.

Text and Writing

Case Converter

Convert text between UPPER, lower, Title, Sentence, camelCase, snake_case, kebab-case, CONSTANT_CASE, and PascalCase.

Text and Writing

List Converter

Transform lists between formats - comma-separated, newline, bulleted, numbered, JSON array, SQL IN clause, and HTML.

Text and Writing