Sort numbers in a list

Order valid decimal values numerically while retaining their exact spelling and keeping every invalid line visible.

Runs in your browser. Your text is not uploaded.

Worked example

Before

10
2
not a number
-3

After

-3
2
10
not a number

The valid numbers are sorted ascending and the invalid line remains last.

Exactly what this changes

  • A valid line may contain a finite decimal value or scientific notation, with surrounding whitespace ignored only for parsing. Negatives, leading zeros, a leading decimal point, and signed exponents are accepted. The displayed line is never reformatted.
  • Lines containing hexadecimal notation, Infinity, NaN, units, comments, or partially parsed numbers are invalid. They are moved below all valid values and remain in their original relative order instead of being deleted or coerced.
  • Values that compare equally are stable. For example, “2”, “2.0”, and “02” keep their input order even though they share a numeric value. A visible status note reports how many invalid lines remain.

Options and edge cases

  • Ascending places the smallest valid value first; descending places the largest first. Invalid entries stay at the bottom in both directions because direction applies only to successfully parsed numbers.
  • Whitespace is not trimmed from the result. Add Trim lines as a separate pipeline step if surrounding spaces should actually be removed rather than merely ignored during numeric parsing.

Edge case: Numbers beyond JavaScript’s finite numeric range are treated as invalid. This is a sorter for plain numeric lines, not arbitrary-precision accounting or regulated financial calculation.