Random Groups

Random order generator

Press Draw to shuffle the list

Local · Fisher–Yates, uniform, without replacement

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

1 Paste your list, one item per line. Blank lines and stray spaces are trimmed away before the shuffle.
2 Draw. Every item appears exactly once, numbered from one.
3 Copy the result. Add a seed first if you need to reproduce the same order later.
4 For a turn that has to come round evenly, shuffle once and then cycle that order, rather than redrawing each time.

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.

MDN, Crypto.getRandomValues()ECMAScript — Array.prototype.sort and consistent comparators
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding