Random order generator
Press Draw to shuffle the list
Paste a list and get it back in a random order, numbered from one. Every line appears exactly once: this is a shuffle rather than a series of picks, so nothing repeats and nothing is dropped. Useful for a presentation running order, a playlist, a rota, or the order people speak in a standup.
How to shuffle a list
This is a shuffle, which means the draw is without replacement: each line is placed in exactly one position and no line can appear twice. A picker or a wheel is the other kind, drawing with replacement, where spinning twice can land on the same name twice. Confusing the two is how a rota ends up with somebody down for two slots and somebody else for none.
The algorithm is Fisher–Yates, walking the list from the end and swapping each item with a uniformly chosen earlier one. With the seed box empty, every choice comes from crypto.getRandomValues with rejection sampling, so all orderings are equally likely: for the eight names loaded by default, all 40,320 of them.
The tempting alternative is sort(() => Math.random() - 0.5), and it is not equivalent. A comparator that answers differently each time it is asked about the same pair is not a consistent comparator, and the ECMAScript specification is explicit about the consequence: "the sort order is implementation-defined if sortCompare is not a consistent comparator". The result is whatever falls out of the engine’s sorting algorithm, which is neither uniform nor stable between engines. It looks shuffled and is not.
A seed swaps in a deterministic generator with 32 bits of state, so the same seed and list always give the same order. That covers roughly 4.29 billion possibilities, which comfortably exceeds the orderings of any list up to twelve items and falls short from thirteen upward, where there are 6.2 billion arrangements. For a running order it makes no practical difference; for anything where you want an unpredictable result, leave the box empty.
A fair shuffle is not a fair rota, and the difference bites weekly. Reshuffling a standup order every morning gives everybody the same chance of going first each day, and that is precisely why the outcome looks unfair over a fortnight. With eight people over ten standups, the chance that any particular person never goes first is (7/8) to the tenth, about 26%, so on average two of the eight will not have opened a single meeting while somebody else has done it three times. Nothing has gone wrong; independence produces clumps. If the aim is that everyone takes a turn, shuffle once and then walk down the list day after day, reshuffling only when the cycle completes. That is a rotation, and it is a different thing from a draw.
Two smaller behaviours. Duplicate lines are kept, because a list of ten "yes" and five "no" is a legitimate thing to shuffle and silently collapsing it would be worse. Blank lines and surrounding whitespace are dropped, so a pasted spreadsheet column with trailing empty rows comes out clean.
What people use it for
- Setting the speaking order for a standup so the same person is not always first
- Deciding who presents last on a Friday afternoon
- Shuffling question order before a quiz is handed out
- Putting a rota of names into an order everyone accepts
- Randomising a playlist an app insists on playing in sequence
- Producing a starting order for a rotation you then cycle through
- Randomising the order of a list of test cases or interview questions
Questions
With the seed box empty, yes. Fisher–Yates over crypto.getRandomValues with rejection sampling gives a uniform permutation, so all 40,320 orderings of eight names are equally probable.
Without. Every line lands in exactly one position, so nothing repeats and nothing is lost. A wheel or picker draws with replacement and can land on the same name twice.
Because a comparator that answers differently each time is not consistent, and the ECMAScript specification says the sort order is then implementation-defined. The result depends on the engine and is not uniform.
Type a seed before drawing. The same seed and the same list always produce the same order, and a different seed produces a different one.
For any single draw, no. The seeded generator holds 32 bits of state, so from thirteen items upward it cannot reach every possible ordering. Below that it can.
No. Equal chances and equal turns are different guarantees, and a draw only gives the first. Over ten standups with eight people, about a quarter of the time a given person never goes first, so on average two people will not have opened a meeting at all.
Shuffle once and cycle that order, reshuffling only when you reach the end. A rotation guarantees equal turns; a fresh draw each time guarantees only equal chances.
No. Repeated lines stay, in whatever positions they land, because a list with deliberate repeats is a reasonable thing to shuffle.
No. Empty lines and surrounding whitespace are dropped before the shuffle, so a pasted spreadsheet column comes out clean.
Thousands of lines are fine. The shuffle is linear in the length of the list and runs entirely on your device.
No. The list stays in the page and is gone when you close the tab.