The Fisher-Yates shuffle is backward

Team Forward vs Team Backward: devs feud over the 'right' way to shuffle

TLDR: A new take shows the forward way to shuffle a list is just as fair as the classic backward method. The crowd splits between Team Forward (simple, works as you go) and Team Backward (more intuitive), trading jokes and proofs—useful because unbiased shuffles matter for games, apps, and research

Internet math nerds and card sharks collided today over a spicy claim: the classic Fisher–Yates shuffle doesn’t have to run backward — a forward pass works just as fairly. Cue the comment-section fireworks. One stunned reader laughed, 'I’ve always done it the forwards way', turning accidental habit into a flex. Another dubbed it the 'online' move, cheering that you can build a shuffled list on the fly, even if you don’t know how long it’ll be yet. Think playlists, not poker.

Team Backward fired back with casino-table vibes. Their case? The old-school mental picture is easier: pick a random card for the bottom, then the next, and so on — it just feels right. Skeptics confessed they weren’t convinced the forward version is truly fair until a clever analogy (insert-at-random vs swap) clicked. Meanwhile, the brainy twist that forward and backward shuffles are inverse twins had people nodding: if one is uniform, the other is too — every order is equally likely.

The memes flowed: Shuffle kerfuffle, Team Forward jerseys, and good-natured shade at 'fancy proofs' vs 'table instincts.' Underneath the laughs, there’s real impact: fair shuffles matter in games, apps, and research. Whether you go forward, backward, or 'inside-out,' the internet agrees on one thing: drama never randomizes evenly

Key Points

  • The standard Fisher–Yates shuffle iterates backward, swapping element i with a random j in [0, i] to produce a uniform random permutation.
  • A proposed forward_shuffle iterates from i = 1 to n−1, swapping with j in [0, i], and also yields a uniform distribution.
  • Correctness of forward_shuffle is shown by an induction invariant: after each iteration i, the prefix a[0..i] is uniformly randomized.
  • An alternative proof observes that forward_shuffle applies the same random transpositions as Fisher–Yates but in reverse order, yielding inverse permutations, which are uniformly distributed.
  • The forward_shuffle is essentially the inside-out Fisher–Yates approach suitable for streaming/external sources, with optional optimization to skip swaps when j == i.

Hottest takes

"I’ve always done it the forwards way" — robinhouston
"I find the backward version slightly more intuitive" — amluto
"it wasn’t as clear to me that the ‘forward’ version makes a uniform distribution" — fn-mote
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.