Vector shuffling — A JavaScript functional implementation

Giancarlo Radaelli
Nov 27, 2019 · 6 min read

The reshuffling of the elements of a vector can be obtained with two simple and very similar algorithms:

the vector is traversed in one direction (can be indifferently left to right or right to left) and each element is exchanged with an element chosen at random respectively among the successive elements of the vector (Durstenfeld’s algorithm) or among the previous