Skip to content

Sort Lines

Sort lines alphabetically, numerically, by length or randomly.

Processed locally in your browser.

How do you sort lines of text?

Alphabetical sorting uses locale comparison, numeric sorting compares the leading number on each line, length sorts by character count, and shuffle randomises the order. Use numeric sorting so 2 comes before 10, and blank lines are removed from the output. For example, "banana, apple, cherry" sorted A→Z becomes "apple, banana, cherry".

Understanding your result

Use numeric sorting for lists of numbers so that 2 comes before 10. Blank lines are removed from the output.

Formula and method

Alphabetical sorting uses locale comparison; numeric sorting compares the leading number on each line; length sorts by character count; shuffle randomises the order.

Assumptions and limitations

Sorting works on whole lines as text, so numeric mode reads only the leading number on each line and ignores values later in the line. Alphabetical order follows locale rules rather than a custom priority you might have in mind. Blank lines are dropped, and everything runs in your browser.

Worked example

“banana, apple, cherry” sorted A→Z becomes “apple, banana, cherry”.

How to use this tool

  1. Paste your lines.
  2. Choose the sort order and options.
  3. Copy the sorted result.

Common mistakes to avoid

  • Using alphabetical order on numbers (which puts 10 before 2).

About the Sort Lines

Reorder a list of lines alphabetically, numerically, by length or at random, with optional de-duplication.

Who should use this tool

People organising text lists: writers alphabetising references, developers ordering config keys or imports, and anyone arranging names, tasks or data. If you have lines in a jumbled order and want them alphabetical, numeric, by length or shuffled, optionally with duplicates removed, this reorders them at once.

Benefits

  • Sort alphabetically, numerically, by length or at random
  • Numeric mode orders numbers correctly so 2 precedes 10
  • Optionally remove duplicates while sorting in one pass
  • Reorders large lists locally without sending data anywhere

Practical use cases

  • Alphabetising a bibliography or list of names
  • Ordering a numeric list so values rank correctly
  • Shuffling entries to randomise a draw or playlist
  • Sorting config keys or imports for consistency

Explore all Text and Writing tools

Frequently asked questions

Can it shuffle a list?

Yes. Choose “Shuffle” to randomise the order.

Why should I use numeric sorting instead of alphabetical?

Alphabetical sorting treats numbers as text, so 10 comes before 2 because it starts with 1. Numeric sorting compares the leading number on each line by value, keeping 2 before 10. Choose numeric mode whenever your lines begin with figures you want ranked properly.

What happens to blank lines when I sort?

Empty lines are removed from the output rather than clustered at the top or bottom, so your sorted result is a clean list without gaps. If you need to preserve spacing, keep a copy of the original before sorting.

Share this tool

Free to use — copy the link, share it anywhere, or add the tool to your own website.

Embed this tool on your site (free)

Copy this code and paste it into any web page — it stays free and always up to date: