Skip to content

Instantly share code, notes, and snippets.

@Anaminus
Created September 7, 2018 17:06
Show Gist options
  • Select an option

  • Save Anaminus/5f979fda086ead1f81ad0cc4e929dfd7 to your computer and use it in GitHub Desktop.

Select an option

Save Anaminus/5f979fda086ead1f81ad0cc4e929dfd7 to your computer and use it in GitHub Desktop.
Correct 1-index Fisher–Yates shuffle
for i = #a, 2, -1 do
local j = math.random(1, i)
a[i], a[j] = a[j], a[i]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment