Text/Clean

Sort

Sorts lines alphabetically, by number, by length, in reverse or at random.

Example

  • Options used
  • Sort byNumeric value
  • Descending
Input
Coffee 4,500
Tea 3,000
Cake 12,000
Water 800
Menu
Output
Cake 12,000
Coffee 4,500
Tea 3,000
Water 800
Menu

Symbols in examples: ⇥ tab · · trailing space · ⍽ NBSP · □ full-width space · ◌ zero-width character

Open this operation in the tool

What it does

Reorders text line by line. It is a stable sort: lines that compare as equal keep their original order.

Sort modes

  • Alphabetical (natural): uses the browser's language-aware comparison (Intl.Collator), so Korean is sorted in ganada (Korean alphabetical) order and English in alphabetical order. Numbers are compared naturally, so item2 comes before item10.
  • Numeric value: sorts by the first number found in each line. It recognizes thousands separators like 1,200, negative numbers and decimals, and lines with no number go to the end.
  • Length: by character count. Emoji and combining characters are counted one character at a time.
  • Reverse order: flips the order of the lines regardless of their content.
  • Random: shuffles using the browser's cryptographic random number generator. Use it to decide a draw order or presentation order.

Options

'Descending' reverses the order in the alphabetical, numeric and length modes. If you turn off 'Ignore case', uppercase comes first among otherwise identical letters.

A single blank line at the very end of the text (the final line break) is excluded from sorting and stays at the end. Blank lines in the middle gather at the top, so apply Remove blank lines first.