DiceDecide

How to Shuffle a List Fairly

Be the first to rate this page.

A fair shuffle gives every complete ordering of n distinct list entries the same probability. For 4 names there are 4! = 24 possible orders, so one named order has probability 1/24; a correct Fisher–Yates shuffle selects one of those orders without keeping an early-entry advantage.

A worked example with numbers

With four speakers A, B, C, and D, a fair order generator may produce C, A, D, B. There are 4 × 3 × 2 × 1 = 24 possible orders. A’s chance of the first position is 1/4, and after A is first each remaining person has 1/3 chance of second. The list shuffler keeps all four entries exactly once.

How to set the rule before the result

Enter one distinct row per participant, state whether duplicate text represents one person or two entries, and preserve the first output. A random order generator is useful when the positions are the result, while random pairs uses an order only as an intermediate step.

Common mistakes that change the odds or the process

Do not repeatedly pick one name and leave it in the list; that permits repeats. Do not sort with an inconsistent random comparator. Do not redraw because the beginning of a valid order looks inconvenient.

Where this method stops being appropriate

The fairness claim assumes the implementation uses a uniform permutation and that the input is complete. MDN documents the browser random source used by the page in MDN’s Crypto.getRandomValues reference; it cannot decide who belongs on a real-world roster.

How the random source fits into the rule

MDN’s Crypto.getRandomValues reference

Apply the rule to the actual input

Enter one distinct row per participant, state whether duplicate text represents one person or two entries, and preserve the first output. A random order generator is useful when the positions are the result, while random pairs uses an order only as an intermediate step.

Audit the calculation or allocation

With four speakers A, B, C, and D, a fair order generator may produce C, A, D, B. There are 4 × 3 × 2 × 1 = 24 possible orders. A’s chance of the first position is 1/4, and after A is first each remaining person has 1/3 chance of second. The list shuffler keeps all four entries exactly once.

Do not import a different rule by accident

Do not repeatedly pick one name and leave it in the list; that permits repeats. Do not sort with an inconsistent random comparator. Do not redraw because the beginning of a valid order looks inconvenient.

Limit of this specific method

The fairness claim assumes the implementation uses a uniform permutation and that the input is complete. MDN documents the browser random source used by the page in MDN’s Crypto.getRandomValues reference; it cannot decide who belongs on a real-world roster.

Source and reproducibility

MDN’s Crypto.getRandomValues reference

Why each Fisher–Yates position has equal odds

Stage for 4 entriesChoices for swapEffect
Last position4Any entry can be last
Third position3One remaining entry is chosen
Second position2One remaining entry is chosen
First position1Last entry remains

Multiplying the available choices yields 24 paths, one for every four-entry ordering. An implementation must choose the swap index uniformly from the inclusive range 0 through i. Choosing only 0 through i minus 1 prevents an entry from staying in its current position and changes the distribution.

Preserve labels that look duplicated

Two participants named Jordan need distinct labels such as Jordan P. and Jordan R. before the shuffle. De-duplicating them because the text looks the same would remove a real participant; treating an accidental copy of Jordan P. as intentional gives that person two positions. The random algorithm cannot decide which interpretation is true, so that check belongs to the roster owner.

Reproduce this result before relying on it

A uniform shuffle is a random permutation in which every possible ordering of the supplied distinct entries has equal probability. With four speakers A, B, C, and D, a fair order generator may produce C, A, D, B. There are 4 × 3 × 2 × 1 = 24 possible orders. A’s chance of the first position is 1/4, and after A is first each remaining person has 1/3 chance of second. The list shuffler keeps all four entries exactly once.

Choose the action that matches the stated rule

Enter one distinct row per participant, state whether duplicate text represents one person or two entries, and preserve the first output. A random order generator is useful when the positions are the result, while random pairs uses an order only as an intermediate step. Do not repeatedly pick one name and leave it in the list; that permits repeats. Do not sort with an inconsistent random comparator. Do not redraw because the beginning of a valid order looks inconvenient.

What the number does not decide

The fairness claim assumes the implementation uses a uniform permutation and that the input is complete. MDN documents the browser random source used by the page in MDN’s Crypto.getRandomValues reference; it cannot decide who belongs on a real-world roster. MDN’s Crypto.getRandomValues reference

State the complete decision model

A fair shuffle gives every complete ordering of n distinct list entries the same probability. For 4 names there are 4! = 24 possible orders, so one named order has probability 1/24; a correct Fisher–Yates shuffle selects one of those orders without keeping an early-entry advantage. A uniform shuffle is a random permutation in which every possible ordering of the supplied distinct entries has equal probability.

Before publishing or using the outcome

With four speakers A, B, C, and D, a fair order generator may produce C, A, D, B. There are 4 × 3 × 2 × 1 = 24 possible orders. A’s chance of the first position is 1/4, and after A is first each remaining person has 1/3 chance of second. The list shuffler keeps all four entries exactly once. Enter one distinct row per participant, state whether duplicate text represents one person or two entries, and preserve the first output. A random order generator is useful when the positions are the result, while random pairs uses an order only as an intermediate step.

Related DiceDecide tools

Enter your values, review the result, then use it with confidence.

Rate this page

Be the first to rate this page.