有趣的是,微软在他们的选择随机浏览器页面中使用了相同的技术。
他们使用了一个稍微不同的比较函数:
function RandomSort(a,b) {
    return (0.5 - Math.random());
}
对我来说看起来几乎一样,但结果却不是那么随意......
因此,我使用链接文章中使用的相同方法再次进行了一些测试,结果确实 - 结果是随机排序方法产生了有缺陷的结果。新的测试代码在这里:
function shuffle(arr) {
  arr.sort(function(a,b) {
    return (0.5 - Math.random());
  });
}
function shuffle2(arr) {
  arr.sort(function(a,b) {
    return (Math.round(Math.random())-0.5);
  });
}
function shuffle3(array) {
  var tmp, current, top = array.length;
  if(top) while(--top) {
    current = Math.floor(Math.random() * (top + 1));
    tmp = array[current];
    array[current] = array[top];
    array[top] = tmp;
  }
  return array;
}
var counts = [
  [0,0,0,0,0],
  [0,0,0,0,0],
  [0,0,0,0,0],
  [0,0,0,0,0],
  [0,0,0,0,0]
];
var arr;
for (var i=0; i<100000; i++) {
  arr = [0,1,2,3,4];
  shuffle3(arr);
  arr.forEach(function(x, i){ counts[x][i]++;});
}
alert(counts.map(function(a){return a.join(", ");}).join("\n"));