Line Sorter
Reorder complete lines with A → Z, Z → A, Numeric, Shortest first or Longest first. Alphabetical modes use locale-aware natural numeric comparison, so item2 precedes item10 in A → Z. Numeric mode converts the entire line to a number. Sorting preserves duplicates, spaces and blank lines; it is not data cleanup.
Before you copy the result
- A → Z orders item2 before item10.
- Numeric requires clean complete values; blank rows compare as zero.
- Duplicates and whitespace remain in output.
How to use the Line Sorter
- Paste one value per line. Commas remain within a line.
- Choose alphabetical modes for names with embedded digits, Numeric for clean numeric values, or length modes for stored string length.
- Review blank rows and invalid numbers before copying; output updates immediately and uses LF line endings.
Use a consistent comparison rule
A → Z and Z → A use the browser default locale, so accents, punctuation and letter-case order can vary by environment. Natural numeric handling orders embedded digit sequences; it is not a universal decimal-number parser. Use Numeric for ordinary signed decimal values.
Numeric uses Number on each complete line: blank and whitespace-only lines become zero, while “1,000”, “$5” and “10 kg” become NaN. Nonfinite values now show an error and suppress the numeric output, rather than presenting a partially sorted mixed list. Correct the input rows before copying.
Length means stored string length
Length modes count JavaScript UTF-16 code units, including spaces, not visual width or user-perceived characters. An emoji can count as more than one unit. Equal comparison keys retain their input order. This matters when comparing identifiers or aligning text; neither length mode measures rendered columns.
No option trims, deduplicates or discards blanks. Remove accidental spaces before sorting only if they are not meaningful; use Duplicate Line Remover separately when repeats should be removed.
Examples
Leading zero identifiers
A–Z uses natural numeric comparison, so “item02” and “item2” can compare equally and retain their input order. This is useful for filenames but does not establish a unique canonical ordering for identifiers.
Natural order in both directions
Input lines item10, item2 and item1 become item1, item2, item10 in A → Z; Z → A gives item10, item2, item1. Numeric mode is unsuitable for these labels because Number(“item10”) is not a number.
Compare complete numeric values
Input lines 100, -3, 2.5 and 20 become -3, 2.5, 20, 100 in Numeric mode. These represent values, not digit-by-digit text ordering. Thousands separators and unit suffixes must be removed in a separately reviewed cleanup.
Equal lengths keep input order
Input lines fox, cat and elephant become fox, cat, elephant with Shortest first. Fox and cat each have length 3, so their original relative order survives. Longest first gives elephant, fox, cat.
Blank numeric values are zero
Input “2\n\n-1” in Numeric mode produces “-1\n\n2”: the middle empty line converts to zero for comparison but remains empty in output. A trailing newline likewise introduces an empty record.
Choose a mode for the data
| Input lines | Mode | Output lines |
|---|---|---|
| item10 / item2 / item1 | A → Z | item1 / item2 / item10 |
| 100 / 5 / 20 | Numeric | 5 / 20 / 100 |
| fox / cat / elephant | Shortest first | fox / cat / elephant |
Slashes in this table represent separate input/output lines, not delimiters to paste.
Frequently asked questions
Why does item2 come before item10 in A → Z?
Alphabetical sorting compares digit sequences numerically, so item2 sorts before item10 in ascending order.
Why did a blank row move among my numbers?
Numeric converts an empty or whitespace-only line to zero while retaining its original text. Remove unwanted blank records before sorting.
Does shortest mean fewest visible characters?
It means fewest UTF-16 code units. Spaces and multi-unit characters affect the count; it does not measure glyph width or grapheme clusters.
Sources & methodology
More text tools
Duplicate Line Remover
Remove duplicate lines while optionally ignoring letter case and blank lines.
Open tool →Find & Replace Tool
Find and replace plain text or regular-expression matches.
Open tool →Remove Line Breaks
Remove or replace line breaks and normalize whitespace.
Open tool →Case Converter
Convert text between title, sentence, upper, lower, camel, Pascal, snake and kebab case.
Open tool →Word Frequency Counter
Count repeated words and show term frequency.
Open tool →Text Reverser
Reverse characters, words, individual words or lines.
Open tool →