/fisheryates

Package Fisher-Yates shuffles collections of data in the Go Programming Language.

Primary LanguageGoApache License 2.0Apache-2.0

Overview

A generic, typesafe Fisher-Yates shuffle implementation in the vein as Go Programming Language's standard sort.Sort.

	data := sort.IntSlice{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
	rnd := rand.New(rand.NewSource(4)) // Not required; want determinism.
	Shuffle(data, rnd.Intn)
	fmt.Println(data)
	// Output: [6 7 2 4 1 5 9 3 8 0]

Any type that fulfills sort.Interface may be used.

Installation

$ go get -u github.com/matttproud/fisheryates

Documentation

$ godoc github.com/matttproud/fisheryates

GoDoc

Build Status

Build Status