Velocity Reviews > How Not To Shuffle Things Into Random Order

# How Not To Shuffle Things Into Random Order

Lawrence D'Oliveiro
Guest
Posts: n/a

 03-10-2010
Hard to believe Microsoft could do something as stupid as this:

function GenerateBrowserOrder()
{
var aBrowserOrderTop5 = new Array(0,1,2,3,4);
var aBrowserOrderRest = new Array();
for (var i=5; i < dataBrowsers.length; i++)
{
aBrowserOrderRest.push(i);
}
aBrowserOrderTop5.sort(RandomSort);
aBrowserOrderRest.sort(RandomSort);
aBrowserOrder = aBrowserOrderTop5.concat(aBrowserOrderRest);
}

function RandomSort (a,b)
{
return (0.5 - Math.random());
}

<http://www.robweir.com/blog/2010/02/microsoft-random-browser-ballot.html>

Gordon
Guest
Posts: n/a

 03-11-2010
On 2010-03-11, geoff <(E-Mail Removed)> wrote:
> Lawrence D'Oliveiro wrote:
>> Hard to believe Microsoft could do something as stupid as this:
>>
>> function GenerateBrowserOrder()
>> {
>> var aBrowserOrderTop5 = new Array(0,1,2,3,4);
>> var aBrowserOrderRest = new Array();
>> for (var i=5; i < dataBrowsers.length; i++)
>> {
>> aBrowserOrderRest.push(i);
>> }
>> aBrowserOrderTop5.sort(RandomSort);
>> aBrowserOrderRest.sort(RandomSort);
>> aBrowserOrder = aBrowserOrderTop5.concat(aBrowserOrderRest);
>> }
>>
>> function RandomSort (a,b)
>> {
>> return (0.5 - Math.random());
>> }
>>
>> http://www.robweir.com/blog/2010/02/...er-ballot.html

>
> Some people must have really empty lives ....
>
>

Indeed, we replied to this post eh geoff?