, , .
As Alex suggested, the site he provided has a good shuffle feature. I combined this with another function to get the ascii value of the seed.
You should strongly consider changing my example to a hash input. Otherwise there will be many collisions.
Here is the code:
<script>
function ascii_value (c)
{
c = c . charAt (0);
var i;
for (i = 0; i < 256; ++ i)
{
var h = i . toString (16);
if (h . length == 1)
h = "0" + h;
h = "%" + h;
h = unescape (h);
if (h == c)
break;
}
return i;
}
shuffle = function(o,seed){
for(var j, x, i = o.length; i; j = parseInt(seed / (o.length * 255) * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
function seedSort (string){
var charList = string.split('');
var seedValue = 0;
for(var i in charList){
seedValue += ascii_value(charList[i]);
}
return seedValue;
}
document.write(shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],seedSort("bob")));
document.write("<br>");
document.write(shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],seedSort("steve")));
document.write("<br>");
document.write(shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],seedSort("david house")));
document.write("<br>");
document.write(shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],seedSort("acorn22")));
</script>
This will create
8,2,3,4,5,6,7,0,9,1
4,9,3,0,5,6,7,8,1,2
8,0,6,1,5,2,7,3,9,4
4,8,3,0,5,6,7,1,9,2
... which seem random. I would suggest big seeds.