Sort Lines
Sort lines alphabetically, numerically or by text length.
Input Text
Enter one item per line to sort.
Alphabetical ascending
About Sort Lines
Sort Lines arranges text line by line using alphabetical, numerical or length-based sorting. It is useful for organizing lists, URLs, IDs, configuration data and other text-based content.
How to use Sort Lines
- Paste your text into the input area, using one item per line.
- Select the sorting method you want to use.
- Choose whether alphabetical sorting should be case sensitive.
- Enable Trim whitespace to remove spaces around each line before sorting.
- Enable Remove empty lines to exclude blank lines.
- Click Sort Lines to generate the sorted result.
- Use Copy to copy the sorted text to your clipboard.
What does Sort Lines do?
Sort Lines rearranges text so that each line follows the sorting method you select. It supports alphabetical order, numeric order and sorting by the number of Unicode code points in each line. The original text is not modified until you run the sorting operation.
Sorting options
| Option | Description | Example |
|---|---|---|
| A → Z | Alphabetical ascending order | apple, banana, orange |
| Z → A | Alphabetical descending order | orange, banana, apple |
| 0 → 9 | Numeric ascending order | 2, 10, 100 |
| 9 → 0 | Numeric descending order | 100, 10, 2 |
| Shortest → Longest | Sort by Unicode code point count | cat, apple, banana |
| Longest → Shortest | Sort by Unicode code point count in reverse | banana, apple, cat |
Alphabetical sorting
Alphabetical sorting compares text values using the browser's locale-aware string comparison. Choose A → Z for ascending order or Z → A for descending order. When Case sensitive is disabled, uppercase and lowercase letters are compared using lowercase versions of the lines.
banana
apple
orange
Using A → Z sorting produces:
apple
banana
orange
Numeric sorting
Numeric sorting treats valid numeric lines as numbers rather than ordinary text. This means 2 is placed before 10 in ascending order. Decimal and negative values are supported. Lines that are not valid numbers are placed after numeric lines and retain their original relative order.
100
2
25
7
With numeric ascending sorting, the result becomes:
2
7
25
100
Sort by text length
Length sorting arranges lines according to their Unicode code point count. You can sort from the shortest line to the longest or reverse the order. Lines with the same length keep their original relative order.
Case-sensitive sorting
This option affects alphabetical sorting only. When enabled, uppercase and lowercase letters are compared as written. When disabled, the comparison uses lowercase versions of the lines. Numeric and length sorting do not use this option.
Trim whitespace
When Trim whitespace is enabled, whitespace at the beginning and end of each line is removed before sorting. When disabled, the original whitespace is preserved and included in alphabetical and length comparisons.
Remove empty lines
Enable this option to exclude empty lines before sorting. If Trim whitespace is also enabled, lines containing only spaces or tabs are treated as empty lines.
When should you sort lines?
- Sorting lists of names or items
- Organizing URLs or domains
- Sorting IDs or numeric values
- Preparing text for further processing
- Cleaning copied data from spreadsheets
- Organizing configuration or text-based data
Is my text uploaded to a server?
No. Sorting is performed directly in your browser using JavaScript. Your input text is not sent to a server by this tool.
Input limit
The input and result fields support up to 100,000 characters. Larger text may require additional processing resources depending on your browser and device.
Frequently asked questions
Does sorting remove duplicate lines?
No. Sort Lines changes the order of lines but keeps duplicate entries. Use Remove Duplicate Lines if you want to remove them.
Does numeric sorting support decimal and negative numbers?
Yes. Valid decimal and negative numeric values are compared by their numeric value.
What happens to lines that are not numbers?
In numeric sorting, non-numeric lines are placed after valid numeric lines and keep their original relative order.
Does the tool preserve the original order of equal items?
Yes. Lines that compare equally keep their original relative order.
