Sort Lines

Sort lines of text alphabetically, ascending or descending, with optional case-insensitive ordering.

Independently verified for accuracy

Calculator by Toolsloft ↗

Sort lines of text into alphabetical order, ascending or descending, with an option for whether case matters. Paste your lines and copy the sorted result, useful for tidying lists, imports, or config values. Equal lines keep their original relative order.

How this is calculated

Lines are split on line breaks and compared by their text using a stable sort, so lines with equal keys stay in their original order. Descending flips the comparison rather than reversing the list. With case sensitivity off, comparison uses the lowercased form while the original text is preserved in the output.

How to use

  1. Paste the lines you want to sort.
  2. Choose ascending or descending order.
  3. Turn case sensitivity on or off, then copy the sorted lines.

Examples

  • Ascending: banana, apple, cherry becomes apple, banana, cherry
  • Case sensitive: uppercase letters sort before lowercase, so Banana comes before apple

FAQ

Why do capitalized words sort before lowercase ones?
With case sensitivity on, sorting uses character codes, where uppercase letters come before lowercase. Turn case sensitivity off to sort by letter regardless of case.
Is the sort stable?
Yes. Lines that compare as equal keep the order you entered them in, which matters when case-insensitive sorting ties two lines together.
Does it change the text of each line?
No. Only the order changes. Each line is copied through exactly as you typed it, including any spaces.

Embed this calculator

Add this free calculator to your own site. Copy the code and paste it where you want it to appear.