Sort Lines
The two sorting traps this page is built around
Sorting lines sounds too simple to get wrong, and then reality arrives. Trap one is numbers: a character-by-character sort has never heard of place value, so 10 files before 2, version 9 before 10, and Chapter 10 sits between Chapters 1 and 2. Natural order fixes it by reading the digits as numbers. Trap two is case: in raw code-point order every capital letter precedes every lowercase one, so "Zebra" files before "apple" and a pasted list splits into two alphabets. This page sorts with locale rules and case folded, the way a person shelving books would. Around those two fixes sit the cleanup options that do the actual daily work: duplicate removal that ignores stray spaces and case differences (and reports how many it removed), blank-line stripping, and length sorting for finding the outlier lines in a file. One more behaviour worth knowing: the sort is stable, so lines that compare equal (two entries differing only in capitalisation, say) keep the order you pasted them in, and the text of each line is never edited, only reordered. Everything runs locally in your browser; paste a list of ten thousand lines and it sorts in a blink, with nothing uploaded.
Worked example
Input: the seven lines in the box, with banana twice and a capitalised Apple beside a lowercase apple.
A to Z with cleanup: Apple, banana, cherry, item10, item2 (5 lines; 2 duplicates removed, 0 blank). Natural order: Apple, banana, cherry, item2, item10. By length: the two 5-letter entries first (Apple, item2), then the 6-letter ones (banana, cherry, item10). Same input, three correct answers: the right one is the one that matches what the list is for. And note the dedupe subtlety the counts line reports: with case folded, 'apple' counts as a duplicate of 'Apple', so two lines were removed in total (the repeated banana and the lowercase apple). If case variants must both survive in your list, choose 'Keep everything' or sort first and dedupe by eye.
Where sorted lines earn their keep
The everyday jobs are unglamorous and constant: merging two contact lists and removing the overlap, alphabetising a bibliography or a dropdown's options before they ship, checking whether a pasted column of codes contains duplicates before it goes into a database, tidying a guest list, a parts inventory, a set of redirect rules. In each case the value is not the order itself but the anomalies the order exposes: duplicates sit next to each other where the eye can catch them, near-duplicates (the same entry with a typo) become neighbours, and gaps in a numbered sequence show up as holes. Sorting is the cheapest data-quality check there is, which is why it is usually the first thing done to any list that arrives from somewhere else. Keep the original somewhere until you have eyeballed the result: sorting is reversible only if you kept the input.
Frequently asked questions
What is natural sort order and why do I need it?
Plain alphabetical order compares character by character, so 'item10' sorts before 'item2' because '1' comes before '2'. Natural order understands the numbers inside the text and sorts item2 before item10, the way humans and modern file managers expect. Use natural order for filenames, version strings, chapter headings and anything with embedded numbers; use plain order for pure word lists where no numbers are involved.
Is sorting case-sensitive here?
No, by default: comparison uses locale rules with case folded, so 'apple' and 'Apple' sit together alphabetically rather than all capitals being exiled to the top (which is what raw ASCII sorting does, because capital letters have lower code points than lowercase). Ties between lines that differ only in case keep their original relative order. If you need strict code-point order for programming purposes, a code editor's sort is the better tool.
How does duplicate removal decide two lines are the same?
Lines are compared after trimming leading and trailing spaces and folding case, so ' Apple ', 'apple' and 'Apple' count as the same line and only the first occurrence survives. That is the behaviour people want for lists pasted from messy sources. The output tells you how many duplicates and blank lines were removed, so nothing disappears silently; untick the options if you need exact, case-sensitive deduplication instead.
Why sort by length?
Length order surfaces things alphabetical order hides: the longest line in a file (often the one breaking a layout or a parser), the shortest entries in a list (often truncated or empty-ish data), headlines ranked by bulk for editing, and passwords or codes grouped by size. It is also a quick data-quality scan: in a column of postcodes or SKUs, the lines that sort to the ends by length are the malformed ones.
Can this sort numbers, not just words?
Yes, with natural order: lines that are pure numbers sort by value (2, 10, 100), and lines with numbers inside sort by those numbers in place. It is not a spreadsheet, though: it will not sum, and lines mixing text and numbers follow the natural rule rather than extracting a column. For a quick tidy of a one-column list it is exactly enough; for multi-column data, convert to CSV and use a spreadsheet.
Related tools
Sorting rules and worked example last verified: 23 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.