Line Sorter Tool

Paste your lines and choose how to sort them — alphabetically, numerically or by length.

How it is calculated

Each line of the pasted text is one item. Lines that are empty or contain only spaces are dropped first, so the count excludes them. With duplicate removal on, only exact repeats are removed and the first one is kept; the comparison is case-sensitive and counts spaces, so a and a (with a trailing space) are different lines. The sort mode then applies. Alphabetical (A to Z or Z to A) compares the raw characters, so every capital letter comes before every lower-case letter and accented letters such as é or ö come after z. Numeric modes compare the number at the start of each line (10 apples counts as 10); a line without a leading number counts as 0. Length mode orders by the number of characters, shortest first, and keeps the original order of lines of equal length. The output shows the sorted lines and how many remain.

Worked example

Paste four lines: 10 apples, 9 pears, 2 kiwis and 100 figs, choose numeric ascending with duplicates kept. The tool reads the leading number of each line (10, 9, 2, 100) and orders by value, so the output, one line per row, is:

2 kiwis 9 pears 10 apples 100 figs

The count is 4. In plain alphabetical mode the same lines come out as 10 apples, 100 figs, 2 kiwis, 9 pears, because "1" sorts before "2" as a character.

Try this example →

Common mistakes

  • Using alphabetical mode on numbers. As text, 100 sorts before 9 and 10 before 2.5, because lines are compared character by character; choose a numeric mode for values.
  • Expecting a case-insensitive sort. Apple and Banana come before apple and banana, so a list mixing capitals and lower case may look out of order until you make the case uniform.
  • Expecting duplicate removal to ignore case or spacing. apple, Apple and apple are three different lines for the tool, and all three stay.
  • Using a numeric mode on lines that do not start with a number, such as item 10 and item 9. They all count as 0, so their order does not change; use alphabetical mode or remove the prefix.
  • Expecting accented words to sort like their base letters. In alphabetical mode éclair comes after zebra, because the comparison is by character code, not by a language's dictionary order.

About this calculator

Sorting a block of text line by line is a small but constant chore in data cleanup: alphabetical sorting arranges lines by their Unicode/character order, numerical sorting reads the leading number in each line and orders by its value rather than as text (so "10" correctly comes after "9" instead of before it), and sorting by length orders lines from shortest to longest — each useful for a different kind of list.

This tool takes any pasted block of lines, sorts them by your chosen method, and can optionally strip out duplicate lines in the same pass. Developers cleaning up log files or config lists, spreadsheet and CSV users prepping data before import, and writers organizing lists — like alphabetizing a bibliography or de-duplicating an email list — use it instead of writing a one-off script for a task that takes seconds in a browser.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Thousands separators trip up the numeric modes. A line starting with 1,200 is read as 1, because the number stops at the comma, so it lands near the smallest values instead of near 1200. Strip the commas from the numbers before pasting, and place numeric fields at the start of each line. What kind of lists do you usually sort here: logs, names or figures?

Popular calculators

All Calculators