šŸ“Š Sort Lines

Sort and organize text lines alphabetically, numerically, or in reverse order. Perfect for organizing lists, managing data, and arranging text content. Supports ascending and descending sort options.

šŸ“Œ Sorted Output:
Enter text and click "Sort Lines" to organize...
0
Total Lines
0
Blank Lines
0
Content Lines
šŸ’” How it works:
  • Paste your text with one item per line
  • Click "Sort Lines" to organize alphabetically
  • Enable "Reverse Order" for Z→A sorting
  • Blank lines are preserved in sorted output
  • Sort is case-insensitive by default
  • Statistics show total, blank, and content lines

šŸ“ Examples:

Input (Unsorted):
zebra apple mango banana cherry
Output (Ascending Sort):
apple banana cherry mango zebra
Output (Descending Sort - Reverse):
zebra mango cherry banana apple
Input (Numbers & Text):
30-Item 5-Item 100-Item 2-Item 15-Item
Output (Lexicographic Sort):
100-Item 15-Item 2-Item 30-Item 5-Item
Statistics (Example):
Total Lines: 5
Blank Lines: 0
Content Lines: 5
šŸ“š Use Cases:
  • Organize alphabetical lists and directories
  • Sort contact or name lists
  • Arrange data for reports or analysis
  • Organize TODO lists or task priorities
  • Sort product names or inventory items
  • Organize server logs or error lists
  • Create alphabetical indexes or catalogs
ā„¹ļø Note: The sort is case-insensitive and lexicographic (alphabetical). Numbers are sorted by their text representation (so "2" comes after "100"). Blank lines are preserved in their sorted positions.

The sort is lexicographic, not numeric

Lines are compared as text, character by character, after both sides are lowercased:

lines.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))

1, 2, 9, 10, 100   sorts as   1, 10, 100, 2, 9

Nothing is read as a number, so 10 lands next to 1 because both begin with the character 1. The fix is to pad your figures to equal width - 001, 002, 010, 100 - at which point alphabetical order and numeric order are the same thing. Comparison uses localeCompare, your browser's own collation, so éclair files beside eclair rather than after zebra.

Case, blanks and the reverse switch

Leading spaces, bullet characters and opening quotes are part of the line and are compared first, so "Smith and Smith do not sit together. Clean the list up before sorting it.

Frequently asked questions

Why does 10 come before 9 in my sorted list?

Because the comparison is alphabetical: it reads the first character of each line, and 1 comes before 9. Zero-pad the numbers to the same width and they will sort in true numeric order.

Is the sort case-sensitive?

No. Both lines are lowercased before comparison, so capitals do not jump to the top the way they do in a plain ASCII sort, where every uppercase letter ranks ahead of every lowercase one.

How do I sort a list alphabetically in Word or Excel?

Word has Sort on the Home tab under the paragraph controls; Excel uses Data, then Sort A to Z. Pasting the lines here is quicker for a list you are still drafting, and nothing about the text is altered.