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

  1. Paste your text into the input area, using one item per line.
  2. Select the sorting method you want to use.
  3. Choose whether alphabetical sorting should be case sensitive.
  4. Enable Trim whitespace to remove spaces around each line before sorting.
  5. Enable Remove empty lines to exclude blank lines.
  6. Click Sort Lines to generate the sorted result.
  7. 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

OptionDescriptionExample
A → ZAlphabetical ascending orderapple, banana, orange
Z → AAlphabetical descending orderorange, banana, apple
0 → 9Numeric ascending order2, 10, 100
9 → 0Numeric descending order100, 10, 2
Shortest → LongestSort by Unicode code point countcat, apple, banana
Longest → ShortestSort by Unicode code point count in reversebanana, 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.

Your privacy matters

We use optional analytics cookies to understand how our tools are used and improve your experience. These controls apply to Google Analytics only, not advertising preferences. Privacy Policy