Guest User

JS random sort test

a guest
May 30th, 2017
145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f=n=>[...Array(n+1).keys()].sort(_=>.5-Math.random());
  2. a=[0,0,0,0,0,0];
  3. for(n=0;n<1e5;n++){p=f(5);for(i=0;i<6;i++)a[p[i]]+=i;}
  4. console.log(a.map(x=>x/1e5))
RAW Paste Data