Text utilities

Sort Text Lines

Sort a list of lines in ascending or descending case-sensitive order.

Text stays in your browserCopy your result
Text workspace
Text workspace

Edit on the left, review and copy the result on the right.

See the method

Your original text

Runs on your device

Your processed text

Your result

Let’s calculate.

Use the Calculate button to see your result.

Your content is processed locally.

How to use this tool

  1. Enter one item per line, order.
  2. Select Update result to view the result.
  3. Check the method and assumptions below before using the result.

Input reference and sample values

Use the units and choices shown for each field. Sample values are provided for practice, not as recommendations.

InputFormat and unitsSample
One item per lineKeep the structure and separators shown in the sample. Line breaks are retained in this input.pear apple orange
OrderChoose Ascending / Descending.Ascending

Result for these sample inputs

apple
orange
pear
Lines
3

Case-sensitive Unicode order. Duplicates and blank lines are preserved.

Select Try the example in the form to load these values and calculate them again. This replaces the current form inputs. Compare the result with the method and worked explanation below.

The method, explained

Compare lines using JavaScript string ordering, which compares UTF-16 code units. Ascending keeps lower values first; descending reverses the sorted sequence. Each line is treated as text.

A WORKED EXAMPLE

The lines pear, apple and orange sort to apple, orange and pear. Text numbers such as 10 and 2 sort lexically, so 10 appears first in ascending order.

What to keep in mind

Sorting is case-sensitive, not locale-aware dictionary or numeric sorting. Duplicate entries, spaces and blank lines are preserved.

Common questions

Will numbers sort numerically?

No. Each line is text. For example, 10 sorts before 2. Use consistent zero-padding if that suits your list.

Does this remove duplicate entries?

No. Use Duplicate Line Remover when you want to retain only the first occurrence of each exact line.

Methodology maintained by ClarityKit. How these tools are built and checked.