What is the Sort Lines?
The Sort Lines tool alphabetizes and organizes multi-line text lists according to diverse sorting criteria: Alphabetical (A to Z), Reverse Alphabetical (Z to A), Natural Numeric order (properly ordering 1, 2, 10 instead of 1, 10, 2), Length (shortest to longest), and randomized shuffle. It cleans up unorganized lists with zero effort.
Organizing lists alphabetically or numerically is essential for dictionary glossaries, index compilations, coding import statements, CSV row ordering, customer contact lists, and inventory management catalogs.
How to Use the Sort Lines
- Paste Your List: Insert your unorganized list into the input box.
- Select Sorting Criterion: Click A → Z, Z → A, Numeric Sort, or Sort by Length.
- Optional Deduplication: Check 'Remove duplicate lines' to simultaneously deduplicate while sorting.
- Copy Sorted List: Copy your structured list ready for immediate use.
Formula & How It Works
Sorting applies JavaScript's localeCompare with natural numeric collation:
1. Alphabetical (A-Z):
lines.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }))
2. Reverse (Z-A):
lines.sort((a, b) => b.localeCompare(a, undefined, { sensitivity: 'base' }))
3. Natural Numeric Sort:
lines.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))
4. Sort by Length:
lines.sort((a, b) => a.length - b.length)Worked Example: An unorganized list containing ['Item 10', 'Item 2', 'Item 1'] under natural sorting correctly orders as: 1. Item 1, 2. Item 2, 3. Item 10.
Practical Worked Examples
| Sorting Mode | Unsorted Input | Sorted Output |
|---|---|---|
| A to Z | Banana Apple Cherry | Apple Banana Cherry |
| Natural Numeric | Page 10 Page 2 Page 1 | Page 1 Page 2 Page 10 |
| By Length | Elephant Cat Giraffe | Cat Giraffe Elephant |
Common Everyday & Professional Use Cases
Alphabetizing bibliographic references, sorting programming imports, organizing inventory product SKUs, ordering customer name lists, and arranging test data.