ToolJutsu
All tools
Text Tools

Sort Lines

Sort lines alphabetically, numerically, or by length.

Sort by
Direction
Processed on your device. We never see your files.

How to use Sort Lines

What this tool does

The Sort Lines tool reorders the lines of any text block according to rules you choose. Paste a list, pick a sort mode — alphabetical, numerical, or by line length — and choose ascending or descending direction. A case-sensitive toggle controls whether uppercase and lowercase letters are treated the same, and a separate toggle removes blank lines from the result. The sorted output appears immediately as you adjust any setting. There is no submit button; the result is always current.

Why you might need it

Sorting a list by hand is impractical beyond a dozen items, and spreadsheet functions require the data to be inside a cell first. A text file full of words, email addresses, file names, or log entries cannot be sorted natively in a plain text editor. Common scenarios include: alphabetising a glossary or bibliography, reordering a requirements list by ID number, grouping CSS class names alphabetically before committing them to a shared file, sorting a word list by length to find the longest entries quickly, or producing a canonical order for a configuration key list so diffs are easier to read.

Numerical sort is especially useful for ordered lists where a strict text sort would put “10” before “2”. Length sort surfaces your shortest or longest entries at a glance, which is handy when checking that every item in a list fits within a character limit.

How to use it

  1. Paste your list — one item per line — into the input area, or click Load sample for a ready-made example.
  2. Select a sort mode: Alphabetical orders by character value, Numerical orders by the numeric value of each line, and By length orders from shortest to longest (or longest to shortest).
  3. Set the direction to Ascending (A → Z, small → large) or Descending (Z → A, large → small).
  4. Tick Case-sensitive if capitalisation should affect the order.
  5. Tick Remove blank lines to drop any empty lines before sorting.
  6. Copy the result with the Copy output button.

Common pitfalls

Alphabetical sort can surprise people when numbers are involved. The string “10” comes before “2” alphabetically because it starts with “1”, which sorts before “2”. Switch to Numerical mode whenever your list contains numbers and order by value is what you need. The tool marks non-numeric lines in numerical mode by moving them to the bottom rather than failing — this keeps partially numeric lists manageable.

Case-sensitive mode can produce unexpected groupings if your list mixes uppercase and lowercase freely. With case-sensitive on, all capital-letter lines sort before their lowercase counterparts, so you get a block of A–Z followed by a separate block of a–z rather than a single interleaved list. Turning case-sensitivity off blends them together.

Blank lines sort to the very top in ascending alphabetical and ascending-length modes because they are the shortest and alphabetically earliest possible line. If that is not what you want, tick Remove blank lines.

Tips and advanced use

Combine Sort Lines with Remove Duplicate Lines: paste a raw list, remove duplicates first, then paste the result here and sort alphabetically for a clean, canonical, non-repeating list in a few seconds. This workflow handles what would otherwise require a spreadsheet or a script.

Length sorting is a quick quality check for anything with a character limit. Sort descending and immediately see the longest lines at the top — useful for checking that every tweet, meta description, or product title fits its constraint before you publish.

For developers, sorting import statements or CSS property lists alphabetically makes reviews faster and merges cleaner. Paste the block, sort ascending, copy back. Because nothing leaves your browser, it is safe to paste real data including internal lists, customer IDs, or private configuration values.

Frequently asked questions

Is my text processed on a server?
No. Sorting happens entirely inside your browser. Your text is never sent anywhere — no upload, no log, no storage. You can safely sort confidential lists, internal data, or anything else private.
What is the difference between alphabetical and numerical sorting?
Alphabetical sorting compares lines as strings, character by character, so '10' sorts before '9' because '1' comes before '9' in the alphabet. Numerical sorting parses each line as a number first, so '9' correctly sorts before '10'. Lines that cannot be parsed as numbers sink to the bottom.
Does it handle lines with mixed numbers and text?
In numerical mode, the tool reads the leading number from each line. Lines that do not start with a recognisable number are treated as non-numeric and sorted to the end, while the numeric lines sort among themselves. In alphabetical mode everything is compared as text.
How does case-sensitive sorting work?
When case-sensitive is on, uppercase letters sort before lowercase (A before a) following standard Unicode order. When off, comparison is done on lowercase versions of the lines, so 'Apple' and 'apple' are treated as equal and their relative order depends on the sort algorithm's stability.
What happens to blank lines?
By default blank lines are kept and sort to the top in ascending mode (they are shorter than everything else in length mode, and alphabetically earlier in alpha mode). Tick 'Remove blank lines' if you would prefer them gone from the output entirely.

Related tools