Shuffle a List

Paste a list and shuffle it into a random order.

Your list (8 examples)

  • Ava
  • Ben
  • Chloe
  • Daniel
  • Ella
  • Finn
  • Grace
  • Henry

These are examples. Add your own and they disappear.

Last reviewed:

How the Fisher-Yates shuffle works

The shuffle walks backward through the list. At each position it picks a random item from the part that isn't fixed yet, including the item already there, and swaps the two. When it reaches the front, every item has been placed exactly once, and every possible order was equally likely.

Example: shuffling A, B, C, D

  1. Position 4: pick from A, B, C, D. Say C. Swap C and D: A, B, D, C
  2. Position 3: pick from A, B, D. Say A. Swap A and D: D, B, A, C
  3. Position 2: pick from D, B. Say B. It stays where it is: D, B, A, C
  4. Position 1 is whatever is left

The shuffled list is D, B, A, C. With 4, then 3, then 2 choices, there are 4 × 3 × 2 = 24 equally likely paths, one for each of the 24 possible orders.

The method was described by the statisticians Ronald Fisher and Frank Yates in 1938 as a pencil-and-paper procedure. The faster version computers use was published by Richard Durstenfeld in 1964 and later made famous by Donald Knuth, which is why it's sometimes called the Knuth shuffle.

Why shortcut shuffles are biased

A shuffle can look reasonable and still favor some orders. A common mistake is to go through the list and swap each item with any position in the whole list, instead of only the positions not yet fixed. For three items that creates 3 × 3 × 3 = 27 equally likely paths, but there are only 6 possible orders. Since 27 can't be split evenly six ways, some orders must come up more often than others.

Sorting a list with a random comparison is another popular shortcut, and depending on the sorting method underneath it can be badly lopsided. Fisher-Yates sidesteps both problems with exactly one random choice per position.

How many orders a list can have

The number of possible orders for n different items is n factorial, written n!: n × (n − 1) × (n − 2) and so on down to 1. It grows startlingly fast, and you can check any of these on the Scientific Calculator.

ItemsPossible orders
36
5120
840,320
103,628,800
20about 2.4 × 10^18
52 (a deck of cards)about 8.07 × 10^67

Even a class of 20 is beyond brute force. At a million shuffles a second, working through every order of 20 names would take roughly 77,000 years.

Ways to use a shuffled list

  • Presentation or speaking order for a class, a team meeting or a talent show.
  • Quiz and test questions, so students sitting side by side get different orders.
  • A chore or duty rota: shuffle once, then rotate through it week by week.
  • Flashcards and vocab lists, so you learn the words rather than the order they come in.
  • Random samples: shuffle a list of 200 customers and contact the first 10.
  • Playlists, reading lists and turn order for board games.

Example: 25 presentations over 5 days

  1. Paste all 25 names and shuffle once
  2. Monday takes lines 1 to 5, Tuesday 6 to 10, Wednesday 11 to 15, Thursday 16 to 20 and Friday 21 to 25

Everyone gets a random slot, and each day has exactly five presentations.

Shuffling to remove order effects

The position of something in a list can change how people treat it. In a taste test, the first sample is tasted with a fresh palate; in a survey, an early question can color the answers that follow; in a presentation lineup, going first or last feels different from going in the middle. Shuffling doesn't remove these effects, but it spreads them fairly, so no single item always gets the advantage.

Example: a blind cookie taste test

  1. Label the four batches A, B, C and D
  2. Shuffle the four letters once for each taster and write down the order
  3. Each taster tries the cookies in their own order and scores them

With a decent number of tasters, each batch goes first about equally often, so the winner can't simply be the one that always went first.

Tips for clean results

  • Put one item per line. Blank lines and stray spaces around items are ignored, and a single comma-separated line works too.
  • Duplicate lines are kept, so an item listed twice appears twice in the result.
  • The copied result has no numbers in front, so it pastes straight into a document, a chat or a spreadsheet column.
  • Each shuffle is independent of the last, so shuffling again gives a fresh order, not a variation on the previous one.
  • To cut the shuffled list into groups in one step, use the Team Generator.

Sources and further reading

How to use it

  1. 1Paste your list, one item per line.
  2. 2Press Shuffle.
  3. 3Copy the shuffled list.

Questions

Is it really random?

Yes. Results come from your browser's cryptographically secure random generator (crypto.getRandomValues), the same source used for security keys.

Which algorithm is used?

The Fisher-Yates shuffle, so every possible order is equally likely.

Also handy: Sort Lines Alphabetically, Classroom Timer, Online Timer