Skip to main content
Back to tools

Sort Lines

Sort lines alphabetically, numerically, by length, or randomly

About Sort Lines

Reorders the lines you paste in six ways: A to Z, Z to A, shortest or longest first, by leading number, or at random, updating the output as you type or switch modes. Alphabetical modes are not natural sorts, so item10 lands before item2. Useful for tidying word lists, import statements or config keys before a diff.

Category: Text.

Frequently asked questions

Is the sort case-sensitive?

▾

No. The A to Z and Z to A modes use your browser's locale-aware comparison (localeCompare), so words are ordered alphabetically regardless of case, as in apple, Apple, banana, Banana; lowercase comes first only when two lines differ just in case. Accented letters sort next to their base letter.

Can I sort numerically?

▾

Yes. Numeric mode reads the number at the start of each line with parseFloat, so 9 comes before 10 and negative or decimal values are ordered correctly. It only sorts ascending, and lines that don't begin with a number can end up in unpredictable positions.

Can I sort in reverse order?

▾

Yes for text and length: Z to A reverses the alphabetical order and Longest first reverses Shortest first. Numeric mode has no descending option, so there is no largest-to-smallest sort.

What happens to blank lines?

▾

Empty lines and lines containing only spaces are removed from the output. Every other line is kept exactly as typed, so leading spaces are preserved and can move a line to the top of an alphabetical sort.

Related tools