All Over Tools logo
Tool Combiner
Analyze Tools Clean Tools Compare Tools Convert Tools Data Validation Extract Tools Format Tools Generate Tools Organize Tools Transform Tools
Image Tools Video Tools Audio Tools Subtitle Tools Font Tools
Analyze Tools Clean Tools Compress Tools Convert Tools Edit Tools Extract Tools Generate Tools Merge Tools Organize Tools Redact Tools Repair Tools Split Tools
Analyze Tools Clean Tools Compare Tools Convert Tools Extract Tools Generate Tools Merge Tools Transform Tools Validate Tools
Business Calculators Construction Calculators Date And Time Calculators Education Calculators Financial Calculators Food Calculators Health Calculators Math Calculators Science Calculators Sports Calculators Statistics Calculators
Blog About Us Contact Us

Sort Lines

Sort complete lines of your text into a chosen order while preserving the characters within each line. Choose alphabetical, numeric, natural, or length-based sorting, ascending or descending, with case, whitespace, blank-line, and line-ending controls.

Sort lines in your browser

Paste text into the input box or use Upload to load a text file. Choose how to order the lines; the result updates automatically whenever the text or options change.

Sorting runs in browser JavaScript. The tool changes the order of complete lines while preserving the characters within each line. It does not sort words inside a line or remove duplicate lines.

Choose the sorting options

  • Sort by: choose Alphabetical, Numeric, Natural (numeric-aware), or Line length.
  • Order: choose Ascending or Descending.
  • Blank lines: choose Sort with other lines, Keep at top, or Keep at bottom. Empty and whitespace-only lines count as blank.
  • Case-sensitive: compare uppercase and lowercase letters as distinct characters when enabled.
  • Ignore leading/trailing whitespace: trim both ends for comparison without changing the stored line. This also means Line length uses the trimmed comparison key.
  • Line ending: use Auto (match input), LF (\n), or CRLF (\r\n) for the output separators.

Sort pasted text or an uploaded file

  1. Paste one entry per line, or select Upload. The file picker accepts .txt, .csv, .log, .md, and text/plain files.
  2. Choose Sort by, Order, the blank-line policy, and any comparison options.
  3. The sorted output updates automatically as you type, upload text, or change an option.
  4. Use the Copy tooltip action to copy the output, or use Download to save it as sorted-lines.txt.

The statistics line reports the number of input lines, output lines, and blank lines after sorting. It is empty when the input is empty.

Understand the sorting behavior

  • Alphabetical compares line text using the selected case and whitespace settings.
  • Numeric uses parseFloat with a numeric pattern that is not anchored at the end. For example, 12abc can be treated as numeric. Non-numeric lines remain after numeric lines in both ascending and descending order.
  • Natural (numeric-aware) treats digit runs inside mixed text as numbers, so item2 can sort before item10.
  • Line length compares the selected comparison key, so leading and trailing whitespace is excluded when that option is enabled.
  • When lines compare equally, their original relative order is kept.

Important limitations

  • An empty input produces no output and no statistics.
  • Only text is read from an uploaded or dropped file. The page does not provide a file-reading error report.
  • The output keeps each line's characters. The selected Line ending setting can change the separators between lines.
  • Sorting runs automatically whenever the input or a sorting option changes.

Common questions

Does sorting change the content of any line?

Only the order of complete lines changes. Words, punctuation, and characters inside each line are preserved; line separators can change according to the selected Line ending option.

What is the difference between numeric and natural sort?

Numeric sort uses parseFloat with a numeric pattern that can accept a numeric prefix such as 12abc. Natural (numeric-aware) sort compares text while treating digit runs inside a line as numbers, so item2 can sort before item10. Non-numeric lines remain after numeric lines in both ascending and descending order.

What happens to blank lines when sorting?

Choose whether blank lines are sorted in with everything else, or held at the top or bottom while the remaining lines sort. Blank lines are never deleted.

What happens when two lines are equal for sorting purposes?

The sort is stable: lines that compare equal under the chosen rule keep their original relative order in the output.

Related Tools

3 views