List randomizer
Paste names, tasks or anything else, one per line, and get them back in a random order where every arrangement has the same chance.
How the list is shuffled
The randomiser uses the Fisher–Yates shuffle, the method described by Knuth as Algorithm P. It works from the end of the list: the last place is filled by an item chosen at random from all of them, the place before it by an item chosen from those left, and so on until one item remains for the first place.
With 4 items the first choice has 4 options, the next 3, then 2 and 1, giving 4 × 3 × 2 × 1 = 24 equally likely sequences of choices. Each leads to a different order, and there are exactly 24 orders of 4 items, so every order has the same 1 in 24 chance. The same holds for any length: n! sequences of choices, one for each of the n! orders.
Each choice is a random position drawn from your browser’s cryptographic generator by rejection sampling, which keeps every position equally likely instead of slightly favouring the low ones. With “Keep the first line at the top” ticked, the first line is set aside before the shuffle and printed above the result unnumbered.
Why simpler shuffles are biased
A common shortcut is to go through the list and swap each item with one at any position, chosen from the whole list every time. It looks just as random, but with 3 items it makes 3 × 3 × 3 = 27 equally likely sequences of swaps, and 27 can’t be split evenly between the 6 possible orders. Following all 27 through gives:
| Result from A B C | Swap with any position | Fisher–Yates |
|---|---|---|
| A B C | 4 in 27 (14.8%) | 1 in 6 (16.7%) |
| A C B | 5 in 27 (18.5%) | 1 in 6 (16.7%) |
| B A C | 5 in 27 (18.5%) | 1 in 6 (16.7%) |
| B C A | 5 in 27 (18.5%) | 1 in 6 (16.7%) |
| C A B | 4 in 27 (14.8%) | 1 in 6 (16.7%) |
| C B A | 4 in 27 (14.8%) | 1 in 6 (16.7%) |
The bias grows with the list. With 4 items the shortcut has 256 sequences for 24 orders, and the most likely order, B A D C, comes up 15 times in 256 (5.9%) while D A B C comes up 8 times (3.1%), against a fair 4.2% each.
Sorting a list with a comparison that answers at random is biased too, and how badly depends on the sorting method. With a textbook insertion sort and a coin toss for every comparison, the 3-item list stays as A B C a quarter of the time, and B A C also has a 25% chance, while the other four orders get 12.5% each. A program that calls its language’s sort with a random comparison inherits whatever bias that sort’s method produces.
How many orders a list can have
The number of orders of n items is n! (n factorial), the product of the whole numbers from 1 to n. It grows faster than any power. Shuffling 20 items once a second, you would wait on average about 77,000 million years to see one particular order.
| Items | Possible orders | Chance of one order |
|---|---|---|
| 3 | 6 | 1 in 6 |
| 5 | 120 | 1 in 120 |
| 8 | 40,320 | 1 in 40,320 |
| 10 | 3,628,800 | 1 in 3,628,800 |
| 13 | 6,227,020,800 | 1 in 6,227,020,800 |
| 20 | about 2.43 × 1018 | 1 in 2.43 × 1018 |
| 52 | about 8.07 × 1067 | 1 in 8.07 × 1067 |
The size of these numbers matters for the generator behind the shuffle. A generator started from a 32-bit seed can produce at most 4,294,967,296 different shuffles, fewer than the orders of 13 items and a tiny fraction of those of 20, and choosing among all orders of 52 items needs about 226 bits of randomness. This page draws every position fresh from your browser’s cryptographic generator instead of a small seed.
What people use it for
| Use | How to set it up |
|---|---|
| Order of speakers or presentations | One name per line; the first in the result goes first |
| A seating plan | Shuffle the guests, then fill the seats in order around each table |
| A rota for chores or duties | Shuffle once, then work down the list week by week so everyone takes a turn before anyone repeats |
| Quiz or survey questions | Paste the questions to stop the same ones always coming first |
| A column copied from a spreadsheet | Tick “Keep the first line at the top” so the column title stays first, then copy the result back as lines |
For a draw where only the first few places matter, such as prizes, the random name picker does the same job and keeps a timed record of each draw.
Questions
Is every order equally likely?
Yes. The list is shuffled with the Fisher–Yates method using your browser’s cryptographic generator, which gives each of the n × (n − 1) × … × 1 possible orders exactly the same chance. A list of 8 items has 40,320 possible orders, each with a 1 in 40,320 chance.
Why are some items still in the same place?
Because a random order doesn’t avoid the original one. Each item has a 1 in n chance of landing back where it started, so on average one item stays put whatever the length of the list, and for lists of more than a few items at least one does in about 63% of shuffles. If no item may keep its place, as in a gift exchange, shuffle again until none does.
Does “Shuffle again” build on the last order?
No. Each shuffle starts from the list in the box, and every shuffle is independent of the ones before, so the same order can come up twice, though with 10 items that happens only 1 time in 3,628,800.
What happens to blank lines and repeats?
Blank lines are dropped and spaces at the ends of lines are trimmed. Repeated lines are kept unless you tick “Remove duplicate lines”, which compares lines without regard to capital letters and keeps the first.
Is my list sent anywhere?
No. The shuffle happens in your browser and the list stays in the text box on your device. The address bar keeps only the two settings, so a shared link opens with the example list.