Why use Sort Lines
Paste a list with one item on each line and pick an order from the Sort by menu: Alphabetical A to Z or Z to A, Numeric low to high or high to low, Length short to long or long to short, or Reverse current order. Alphabetical sorting ignores capital letters and accents and reads numbers inside text as numbers, so item2 comes before item10 and Apple sits beside apple. Tick Remove duplicates to keep one copy of each repeated line. Every line is trimmed of spaces at both ends and blank lines are dropped before sorting. The result shows how many lines came out and can be copied or downloaded as sorted.txt.
The seven sort orders compared
Input, in this order: banana, apple, cherry, apple, date, banana, elderberry. The two numeric rows use a list of numbers instead.
| Sort by | Result |
|---|---|
| Alphabetical (A → Z) | apple, apple, banana, banana, cherry, date, elderberry |
| Alphabetical (Z → A) | elderberry, date, cherry, banana, banana, apple, apple |
| Length (short → long) | date, apple, apple, banana, cherry, banana, elderberry |
| Length (long → short) | elderberry, banana, cherry, banana, apple, apple, date |
| Reverse current order | elderberry, banana, date, apple, cherry, apple, banana |
| Alphabetical (A → Z) with Remove duplicates | apple, banana, cherry, date, elderberry |
| Numeric (0 → 9) on 10, 9, 100, 1.5, -3, 25 | -3, 1.5, 9, 10, 25, 100 |
| Numeric (9 → 0) on 10, 9, 100, 1.5, -3, 25 | 100, 25, 10, 9, 1.5, -3 |
In the length orders, lines of equal length stay in the order you pasted them, which is why banana, cherry, banana are not regrouped.
How alphabetical order handles numbers, capitals, accents and symbols
Each row shows the real A to Z result for a small list.
| List pasted | Sorted A to Z | What it shows |
|---|---|---|
| item10, item2, item1, item20, item3 | item1, item2, item3, item10, item20 | Digits inside text are compared as numbers |
| v1.10.0, v1.2.0, v1.9.3, v2.0.0 | v1.2.0, v1.9.3, v1.10.0, v2.0.0 | Version numbers come out in release order |
| 12 Main St, 9 Oak Ave, 101 Pine Rd | 9 Oak Ave, 12 Main St, 101 Pine Rd | Leading numbers sort by value |
| banana, Apple, cherry, apple, Banana | Apple, apple, banana, Banana, cherry | Case is ignored; ties keep pasted order |
| zebra, Éclair, eclair, Ångström, apple, öl | Ångström, apple, Éclair, eclair, öl, zebra | Accented letters sort with their base letter |
| Chapter 2, Chapter 10, Appendix, _notes, #tag, 42 | _notes, #tag, 42, Appendix, Chapter 2, Chapter 10 | Symbols first, then numbers, then letters |
| the cat, The Beatles, a dog, An owl | a dog, An owl, The Beatles, the cat | Leading A, An and The are not skipped |
| 2026-03-01, 2025-12-31, 2026-01-15 | 2025-12-31, 2026-01-15, 2026-03-01 | Year-first dates sort chronologically |
| 03/01/2026, 12/31/2025, 01/15/2026 | 01/15/2026, 03/01/2026, 12/31/2025 | Month-first dates do not: the year is compared last |
Numeric sorting: what works and what does not
Numeric modes read each whole line as a number. A line that is not purely a number is treated as zero.
Plain numbers with decimals and a negative
10 / 9 / 100 / 1.5 / -3 / 25, Numeric (0 → 9)
-3 / 1.5 / 9 / 10 / 25 / 100
A column with a header, a currency sign and a thousands comma
$40 / 1,200 / 15 / Total / 7, Numeric (0 → 9)
$40 / 1,200 / Total / 7 / 15
$40, 1,200 and Total cannot be read as numbers, so they count as 0 and collect at the low end in their pasted order. Remove symbols and separators first.
Lines that start with a number but contain words
3 apples / 10 pears / 2 kiwis, Numeric (0 → 9)
3 apples / 10 pears / 2 kiwis (unchanged)
Use Alphabetical (A → Z) for this kind of list. It gives 2 kiwis / 3 apples / 10 pears.
Decimals written without a leading zero
0.5 / .25 / 1e2 / -0.75 / 3, Numeric (0 → 9)
-0.75 / .25 / 0.5 / 3 / 1e2
Scientific notation is understood, so 1e2 is placed as 100.
Things to know before you paste
- One item per line. A comma-separated list on a single line is one line and will not be split.
- Blank lines are removed and spaces at the start and end of each line are stripped, in every mode including Reverse current order.
- Remove duplicates is an exact match after trimming, and it is case sensitive: apple, Apple and APPLE are kept as three lines. The first copy of a repeated line is the one that stays.
- Duplicates are removed before sorting or reversing.
- Length is counted in characters, spaces and punctuation included. Most emoji count as 2.
- Lines are compared from their first character. To sort by a surname or a second column, that part needs to come first on the line.
- The alphabetical modes follow English ordering rules. Languages with their own alphabetical conventions, such as Swedish, may expect a different position for some letters.
- There is no random shuffle option.
Sorting lines in Excel, Word, VS Code and the command line
If the list already lives in another program, you may not need to paste it anywhere.
In Excel or Google Sheets, select the column and use Sort A to Z on the Data tab or menu. In Word, select the lines and use the Sort button on the Home tab, which sorts paragraphs as text, numbers or dates.
In VS Code, select the lines, open the Command Palette and run Sort Lines Ascending or Sort Lines Descending. On macOS and Linux, sort file.txt sorts alphabetically, sort -n numerically, sort -r in reverse, sort -u drops duplicates and sort -V handles version numbers.
The difference is in the defaults. Some of these sort by raw character codes unless told otherwise, which puts every capital letter ahead of every lowercase one, and most put item10 ahead of item2. This page applies case-insensitive natural order without any flags.
Step by step
- 1
Paste your list into Lines with one item per line.
- 2
Choose an order under Sort by. Alphabetical (A → Z) is the default.
- 3
Tick Remove duplicates if each entry should appear only once.
- 4
Read the Sorted lines panel. The number in its heading is the line count after blanks and duplicates are removed.
- 5
Copy the result or download it as sorted.txt.