Fisher-Yates Shuffle

Fisher-Yates Shuffle is a simple algorithm for shuffling a finite set. The above demo shows the algorithm in action, exchanging the position of the last and a random element from a subset that decrements in size by one until the set is empty.

The source code for the demo above is a bit lengthy as it involves some visual aids and tweening, so below is a simplified version of the algorithm for shuffling a set of integers: