Skip to content

Instantly share code, notes, and snippets.

@koozdra
Created June 15, 2020 15:27
Show Gist options
  • Save koozdra/8b7d4e2aa2da296423547fb1de9d58f9 to your computer and use it in GitHub Desktop.
Save koozdra/8b7d4e2aa2da296423547fb1de9d58f9 to your computer and use it in GitHub Desktop.
javascript shuffle
shuffle_array = arr =>
arr
.map(a => [a, Math.random()])
.sort(([, lr], [, rr]) => lr - rr)
.map(([a]) => a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment