Sort numeric values in a list

Sort a list of numbers by actual value: `2` comes before `10`, not after it like string-compare sorts. Default is ascending (low→high), numeric mode. Lines that don't parse cleanly as a number (currency like `$5`, plain words, empty lines) parse as `NaN` and keep their input-relative position in the output (stable sort) - for a clean numeric-only result, strip non-numeric lines first. Numeric mode is also available under the general Sort a list tool; this page pre-selects it.

Input
Ready
Output
Live

Numeric compare, not string compare

Lines are compared by their numeric value, not by character order. `2` sorts before `10`; `-5` before `-1`; `0.5` before `0.9`. This is the fix for the classic alphabetical-sort bug where `"10"` lands ahead of `"2"` because `"1"` comes before `"2"` in character order.

Parsing uses JavaScript's `parseFloat`, which is lenient: `3.14`, `-7`, `1e3` (= 1000), `.5`, and `42 apples` (reads the leading number, ignores trailing text) all sort correctly. Currency like `$5`, plain words, and empty lines don't parse and return `NaN`. The exact `parseFloat` rules have edge cases (leading whitespace, `Infinity`, hexadecimal prefixes), so treat the safe summary as: if a line doesn't read as a plain number at a glance, don't assume it sorts predictably.

Lines that parse as `NaN` compare as "equal" to everything under the spec's `NaN`-return coercion to 0. Because `Array.prototype.sort` is stable (ES2019+), they keep their input-relative position: if every line is non-numeric, the output is exactly your input. They can block adjacent numeric lines from crossing them, so for a clean number-only result strip non-numeric lines first with a numeric filter. Equal numeric values also keep their input order by the same stable-sort guarantee.

How to use sort numeric values in a list

  1. 1Enter your list of numbers in the input panel
  2. 2Select 'Ascending' or 'Descending' from Order
  3. 3Choose 'Numeric' in Mode for accurate sorting
  4. 4Toggle 'Case sensitive' if necessary
  5. 5Copy the sorted list from the output panel

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What numeric sort actually does

Numeric value, not character order. Decimals, negatives, and scientific notation all compared as floats.

Real numeric compare, not lexicographic

Lines are compared by numeric value. `2` comes before `10`; `-5` before `-1`; `0.5` before `0.9`. Fixes the classic `"10" < "2"` bug where alphabetical sort puts `10` ahead of `2` because `"1"` precedes `"2"` in character order.

Lenient numeric parsing (parseFloat)

Parsing is prefix-based, so `42 apples` sorts as 42 - the leading number wins and trailing text is ignored. Decimals, negatives, and scientific notation (`3.14`, `-7`, `1e3`, `.5`) all work. Currency, plain words, and empty lines don't parse and return `NaN`. Edge cases of `parseFloat` (leading whitespace, `Infinity`, hex prefixes) have their own rules, so the practical guide is: if a line doesn't read as a plain number, treat its sort position as unreliable.

Equal numeric values keep input order

The ES2019 spec requires `Array.prototype.sort` to be stable, so two lines with the same numeric value retain their original relative order in the output. Useful when lines share a value but differ in trailing annotations you want preserved.

Non-numeric lines keep their input position

Lines that don't parse cleanly as numbers compare as "equal" to everything under the sort's `NaN` handling, which the ES spec coerces to 0. Stable sort means they keep their input-relative position. If every line is non-numeric the output equals the input; in a mixed input they can prevent adjacent numeric lines from crossing them. For a clean number-only result, pre-filter with Filter numbers or remove non-numeric lines manually.

Descending reverses numeric order

Switch Order to descending and the largest numeric values come first. Non-numeric lines behave the same in both directions (still `NaN`, still held in their input-relative position), so descending only visibly affects the numeric items.

Case sensitive is ignored in numeric mode

The Case sensitive toggle only affects alphabetical mode. In numeric mode the comparison is on floats, so case has no meaning - the toggle is inert here and left visible only because the underlying Sort tool shares options across its modes.

Worked example

Five integers in, sorted ascending by numeric value. A string-compare sort would put `12` after `45` because `"1"` follows `"4"`; numeric mode gets it right.

Input
45
12
78
34
56
Output
12
34
45
56
78

Settings reference

How each option changes the output, with the sample above as input.

Setting What it does Effect on the sample
Order: Ascending Sorts numbers from smallest to largest Numbers are ordered as 12, 34, 45, 56, 78
Order: Descending Sorts numbers from largest to smallest Numbers are ordered as 78, 56, 45, 34, 12
Mode: Numeric Sorts based on numeric value Ensures 12 is before 34, not based on string comparison
Case sensitive: On Considers case for text No effect on numeric sorting
Case sensitive: Off Ignores case for text No effect on numeric sorting

FAQ

How does numeric sorting differ from alphabetical sorting?
Numeric sorting compares each line's numeric value, so `2` comes before `10`. Alphabetical compares character-by-character, so `"10"` lands before `"2"` because `"1"` comes before `"2"`.
Can I sort a list that mixes numbers and text?
Only if every line has a clean leading number. `42 apples` sorts as 42 because the parser reads the leading digits, but pure text like `apple` and currency like `$5` don't parse and end up in unreliable positions that can also interfere with where the numeric lines land. For predictable output on mixed input, pre-filter with Filter numbers first, then sort.
Does Case sensitive do anything in Numeric mode?
No - it's inert here. The comparison is on floats, so case has no meaning. The toggle is left visible because the underlying Sort tool shares the same options across all three modes (Alphabetical, Numeric, By length).
Can I sort in descending order?
Yes - switch Order to Descending. Non-numeric lines are still compared as `NaN` in either direction, so descending only visibly reverses the numeric items; anything that couldn't be parsed is still placed unreliably.