Array shuffle without bias


/ Published in: JavaScript
Save to your folder(s)

The usual way to shuffle an array uses the .sort() method with Math.round(Math.random())-0.5
This solution is highly biased based on the sort algorithm used by the browsers. A sort comparison operation has to fulfill the condition "if a>b then b

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.