All Tools

Sort Numbers Online, Ascending or Descending, Free

Sort a list of numbers from smallest to largest or the reverse in your browser. Handles negatives, decimals and exponents, and puts anything that is not a number last. Nothing is uploaded.

Items are separated by
Sort
Order

0 characters, 0 bytes

0 characters, 0 bytes


About sorting numbers

This page sorts a list of numbers by value, from smallest to largest or the reverse. Paste numbers one per line, separated by commas, or split by any other separator, and the sorted list appears at once. It is the List Sorter with the Numeric method already selected. Plain alphabetical sorting gets numbers wrong, because it compares digits as text and puts 100 before 9. Numeric sorting compares what the numbers are worth, so negatives, decimals and exponents all land in the right place. Everything is calculated in your browser.

How to sort numbers

Steps

  1. Paste your numbers into the input. A column copied from a spreadsheet works as it is, because each cell arrives on its own line and New line is the default separator.
  2. For a comma-separated or semicolon-separated list, change Items are separated by to match.
  3. Leave Sort on Numeric, then choose Ascending for smallest first or Descending for largest first.
  4. Copy the result. The note below it gives the item count and says if anything was not a number.

Privacy

The numbers you paste never leave your device. Sorting is done by your browser alone, and nothing is kept after you close the tab.

What counts as a number

An item is read as a number when, after spaces are trimmed, it is made of these parts and nothing else: an optional + or - sign, digits with an optional decimal point, and an optional exponent written with e or E.

  • Accepted: 42, -5, +7, 2.5, .5, 5., 1e3, -1.5e2.
  • Not accepted: 1,000 with a thousands comma, 2,5 with a decimal comma, $12, 45%, 0x1F, 1_000, Infinity, NaN and any word.

Items are sorted by their value but written back exactly as you typed them, so 1e3 stays 1e3 and .5 stays .5. For example, 1e3, 250, -1.5e2, .5, +7 sorts ascending to -1.5e2, .5, +7, 250, 1e3, and descending to 1e3, 250, +7, .5, -1.5e2.

Items that are not numbers

Anything that fails the rules above is moved after the numbers, in the order it appeared, and the note under the output counts it: 10, abc, 2, xyz gives 2, 10, abc, xyz, with a note that 2 items are not numbers and were placed last. Descending order does not move them; 10, abc, 2, xyz descending gives 10, 2, abc, xyz.

This is useful in practice. A column header such as Price, a stray n/a or a value with a currency symbol is pushed to the end where you can see it, instead of being silently dropped or sorted into the middle.

Pasting from a spreadsheet

One column at a time

Copy a single column and paste it here. If you copy several columns, each row arrives as one line with tabs between the cells, and a line like that is not a number. Sort one column per pass.

Formatted cells

A spreadsheet copies cells as they are displayed. A cell showing 1,200 or $35.00 pastes as that text, which this page treats as not a number and places last. Change the cells to plain numbers, or remove the symbols, before copying.

Empty cells

Empty cells arrive as blank lines. Remove blank items is on by default, so they disappear rather than counting as items.

Good to know

  • Numbers with the same value stay in the order you gave them. 2 and 2.0 are equal, so whichever came first stays first.
  • With Remove duplicates on, items are matched as text, so 2 and 2.0 are different items and both stay.
  • Values are compared as ordinary floating-point numbers, so whole numbers above about nine quadrillion cannot always be told apart.
  • For text that merely contains digits, such as item10, numeric sorting is the wrong choice because the whole item is not a number. Switch Sort to Natural, or open the List Sorter.

Related tools

To total, average or find the median of the same list, use the Number List Calculator. The Random Number Generator creates a list of numbers to sort. For text lists, words or mixed items, go to the full List Sorter.

Frequently asked questions

Why does my list of numbers sort as 1, 10, 2 in other tools?

Those tools compare the items as text, character by character, so 10 comes before 2 because the digit 1 precedes 2. Numeric sorting reads each item as a number and compares values, which gives 1, 2, 10. This page starts in Numeric mode for that reason.

Can I sort negative numbers and decimals?

Yes. A leading minus or plus sign is accepted, and so are decimals written with a point, including forms like .5 and 5. Negatives sort below zero as you would expect, so 10, 9, 100, -5, 2.5 becomes -5, 2.5, 9, 10, 100. The output keeps each number written as you typed it.

Does it understand scientific notation such as 1e3?

Yes. An exponent written with e or E, with an optional sign, is read by value, so 1e3 counts as 1000 and -1.5e2 counts as minus 150. The text is not rewritten in the output. Hexadecimal such as 0x1F, and words such as Infinity or NaN, are not treated as numbers.

Why were some of my items moved to the end?

Any item that is not a number by the rules above is placed after all the numbers, in the order it appeared, and the note says how many there were. Typical causes are a column header, an empty marker such as n/a, a currency symbol, a percent sign or a thousands separator.

Why is 1,000 not recognised as a number?

A comma is also the most common list separator, and a comma inside an item could mean a thousands group or a decimal comma depending on country, so the tool does not guess. Remove the separators before sorting, or choose New line as the separator so that 1,000 is not cut in two.

How do I sort a column of numbers copied from Excel or Google Sheets?

Select one column, copy it, and paste it into the input. Each cell becomes a line, which matches the default New line separator, and empty cells are dropped automatically. Copy a single column at a time, because several columns arrive with tabs between the cells and those rows are not numbers.

Does the order of equal numbers change?

No. Items with the same value keep the relative order they had in your list, in both ascending and descending sorts, so 2 and 2.0 stay as entered. Remove duplicates compares the written text rather than the value, so those two are treated as different items and both are kept.

Other related tools