https://github.com/corvuscodex/fisher-yates-js
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place.
https://github.com/corvuscodex/fisher-yates-js
fisher-yates fisher-yates-shuffle javascript javascriptrandom nodejs rng
Last synced: 3 months ago
JSON representation
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place.
- Host: GitHub
- URL: https://github.com/corvuscodex/fisher-yates-js
- Owner: CorvusCodex
- License: mit
- Created: 2020-01-19T15:42:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-08-22T08:55:28.000Z (about 3 years ago)
- Last Synced: 2025-01-21T08:44:54.899Z (9 months ago)
- Topics: fisher-yates, fisher-yates-shuffle, javascript, javascriptrandom, nodejs, rng
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fisher-Yates-JS
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place.How to use:
ADD SCRIPT TO HEAD OF YOUR WEBSITE:
If using downloaded version:
```
```
Using CDN Version:
```
```
Create array:
var newarray = [1,2,3,4,5,6,7,8,9,10];The simply call shuffle function:
newarray = shuffle(newarray);
That's it!