Random Number Generator
Generate random numbers within any range.
Paste any list of numbers, separated by commas, spaces, or newlines, and sort them ascending or descending in one click. Supports integers, decimals, and negative numbers. Optional duplicate removal included.
Order
Separator
This is the single most important thing to understand about sorting numbers. Text is compared character by character from the left, so "10" comes before "9" for the same reason "apple" comes before "banana": the first character 1 sorts before the first character 9, and the comparison stops right there without ever looking at the rest of the string.
JavaScript is the classic trap here. Array.prototype.sort called with no arguments converts every element to a string before comparing, even in an array of numbers. The fix is to pass a numeric comparator: (a, b) => a - b for ascending, or (a, b) => b - a for descending. The comparator should return a negative number when a comes first, a positive number when b comes first, and zero when the two are equivalent.
The same problem appears far beyond JavaScript. Spreadsheet columns imported as text, database columns declared as VARCHAR instead of INTEGER, and CSV files parsed without type coercion all sort this way. If a sorted list looks like 1, 10, 100, 11, 2, the values are being treated as text somewhere upstream.
Ascending order runs from smallest to largest, which is the default nearly everywhere and the right choice for readings you want to scan for a minimum. Descending order runs from largest to smallest and suits rankings, top-N lists, and anything where the interesting values sit at the high end. Negative numbers follow the same rule that they follow on a number line, so -50 is smaller than -3, a detail that string sorting also gets wrong.
Alongside the sorted output the tool summarises the set. Each figure answers a different question about your data.
| Statistic | Meaning | What it tells you |
|---|---|---|
| Count | How many values were parsed | A quick check that nothing was dropped by bad separators |
| Sum | All values added together | Totals for quantities, amounts, and durations |
| Minimum | The smallest value | The first item once sorted ascending |
| Maximum | The largest value | The last item once sorted ascending |
| Mean | The sum divided by the count | The arithmetic average, the centre of mass of the set |
One caution about the mean: it is highly sensitive to outliers. A single extreme value drags it a long way, which is why the mean salary in a small company tells you very little if one person earns ten times everyone else. The median, the middle value once the list is sorted, is robust to that: changing the largest number to something ten times larger does not move it at all. Sorting your data is the first step to reading the median off it, and comparing mean against median is a fast way to spot skew. When the mean sits well above the median, a few large values are pulling it up.
Lexicographic order also produces surprises for strings that contain embedded numbers, which is why a file listing so often looks wrong. Natural sort order fixes this by splitting each string into runs of letters and runs of digits, then comparing the digit runs numerically rather than character by character.
Modern JavaScript can do this with Intl.Collator using the numeric option, and most operating system file managers apply natural ordering by default. If you control the data, an even simpler fix is zero padding the numbers when they are generated, since file001 through file020 sort correctly under plain text comparison.
A sort is stable when items that compare as equal keep their original relative order. This is invisible when sorting plain numbers, and essential when sorting records by several keys in turn. To order employees by department and then by name within each department, you sort by name first and then by department: a stable sort preserves the name ordering inside each department group, while an unstable one scrambles it. JavaScript engines have guaranteed a stable sort since ES2019.
Sorting is usually one step in a data cleanup pipeline. Browse the full data and developer tools collection for formatters, converters, and text utilities that handle the rest.
Sorting a list of numbers is a frequent task in data analysis, spreadsheet cleanup, and programming. This tool handles the common case where you have a raw list, from a CSV export, log file, or code output, and need it ordered quickly without opening a spreadsheet or writing a script. It parses any reasonable delimiter, performs a proper numeric sort (not lexicographic), and lets you copy the sorted result to paste wherever you need it.