Sort lines of text

Order physical lines alphabetically, numerically, by UTF-16 length, or with locale-aware natural collation.

freeworks offlinenothing uploaded
ToolLine Sorter
Input
Output

How it works

Rows split at CRLF or LF, can be trimmed or filtered, and are compared with localeCompare, parseFloat prefixes, JavaScript length, or numeric collation. Descending order negates the comparator before reconstruction with LF.

  • Ascending case-insensitive alphabetical order with trimming is selected first while empty rows remain.
  • Natural and numeric modes are separate because item10 and 10kg require different interpretations.

Worked example

Alphabetical Sort
Sort a list of fruits alphabetically
Input
											banana
apple
cherry
date
avocado
										
Output
												apple
avocado
banana
cherry
date
											

When to use this

Vocabulary lists are alphabetized, item2/item10 filenames use natural order, and measurement rows sort by a leading numeric value.

Edge cases

  • Numeric mode reads 10kg as 10 because parseFloat accepts a numeric prefix.
  • Alphabetical and natural order can vary with the runtime locale rather than raw Unicode code points.
  • Rows with equal comparison keys retain their input order under modern ECMAScript stable sorting.

References