Skip to content
Quaestio

Sort lines

Paste a list with one item per line, and it is reordered according to your choices.

Result

0 lines in, 0 out

Embed

Embed this tool on your site

Copy the code and paste it where the tool should appear, such as a blog post or a school page. It is free, the box has no ads and the tool calculates in the visitor’s browser.

How it works

Sorting follows English alphabetical order. Accented letters sort with their base letter, so é sits among the e words and ö among the o words, as in an English dictionary.

With the case box unticked, Apple and apple sort as the same word, which is almost always what you want.

Numeric sorting compares digits by value rather than character by character. Without it, 100 comes before 9, because one comes before nine.

Duplicates are compared on the line without leading and trailing spaces, so two lines that differ only by a space count as the same.

Original order and reversed order do not sort at all; they only let you remove duplicates or flip the list.

The list stays in your browser.

How lines are compared

Lines are compared with the browser’s collator for British English, which follows the Unicode Collation Algorithm and the sorting data in Unicode’s CLDR. Without the case box ticked, the comparison ignores capitals but not accents, so resume and Résumé are two different lines, and resume comes first whichever order they were in. Spaces at either end of a line are ignored for the comparison but kept in the result.

Letters that English does not use are placed with the nearest English letter. Æ sorts as ae, so Æble lands between Aa and angel, and ø sorts as an accented o. The Unicode Collation Algorithm notes that most languages written in the Latin alphabet treat ø that way, while Danish and Norwegian put it after z. On the Swedish page the same list is sorted the Swedish way, with å, ä and ö after z.

Numeric sorting and its limits

With numeric sorting, every run of digits is compared as a number wherever it sits in the line, so file9 comes before file10. Minus signs and decimal points are not understood, though: −5 comes before −10, and 2.5 before 2.25, because 5 and 25 are compared as whole numbers. Give decimals the same number of places, 2.50 and 2.25, and the order comes out right.

Duplicates and reverse order

Duplicates are compared the same way as the lines are sorted: without the case box, Anna and anna are duplicates and only one of them is kept, while Résumé and resume are both kept. With the box ticked, lower case comes before upper case: a before A.

Reverse alphabetical order is the normal order turned round. Lines that count as equal, meaning they differ only in capitals or in spaces at either end, therefore come out in the opposite order to the one they had in the list.

Sources

How the tools are checked