Hacker News new | ask | show | jobs
by fanf2 173 days ago
There are actually four variants:

• loop counts downwards vs upwards

• the processed part of the array is a uniform sample of the whole array, or it is a segment that has been uniformly shuffled

Knuth described only the downwards sampling version, which is probably why it’s the most common.

The variants are compared quite well on wikipedia https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

1 comments

It's interesting that the two forward versions of the algorithm were added to Wikipedia just a few months ago. (The OP article is from 2020.)