Skip to content

Instantly share code, notes, and snippets.

@danielhaim1
Created March 19, 2023 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielhaim1/66f95642f279ae076a5279fbb5f3ad4e to your computer and use it in GitHub Desktop.
Save danielhaim1/66f95642f279ae076a5279fbb5f3ad4e to your computer and use it in GitHub Desktop.
Sattolo's Algorithm
function sattolosAlgorithm(array) {
const len = array.length;
for (let i = len - 1; i > 0; i--) {
const j = Math.floor(Math.random() * i);
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment