Go package with 6 popular shuffling algorithms
go get github.com/nemzyxt/shuffler
Example:
package main
import (
"fmt"
"github.com/nemzyxt/shuffler"
)
func main() {
arr := [5]int{1, 2, 3, 4, 5}
shuffler.FisherYatesShuffle[int](arr[:]) // use the Fisher-Yates algorithm
fmt.Println(arr)
}
- Fisher-Yates Shuffle
- Knuth Shuffle
- Sattolo's Shuffle
- Durstenfeld Shuffle
- Cohen's Shuffle
- Riffle/Perfect Shuffle