Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Sorts/BogoSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ export function isSorted(array) {
}

/**
* Shuffles the given array randomly in place.
* Shuffles the given array randomly in place using the Fisher–Yates algorithm.
*/
function shuffle(array) {
for (let i = array.length - 1; i; i--) {
const m = Math.floor(Math.random() * i)
const n = array[i - 1]
array[i - 1] = array[m]
array[m] = n
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}

Expand Down
Loading