Advertisement
arxeiss

Shuffle array

May 16th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.24 KB | None | 0 0
  1. // Based on Fisher-Yates algorithm
  2. func shuffleRecipients(shuffle []*data.Recipient) {
  3.     rand.Seed(time.Now().UnixNano())
  4.     for n := len(shuffle) - 1; n > 0; n-- {
  5.         j := rand.Intn(n + 1)
  6.         shuffle[n], shuffle[j] = shuffle[j], shuffle[n]
  7.     }
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement