比如a是的你的数组 然后根据a数组里面每个对象的id属性排序:
var a = []
a.sort(function (o, p) {
return o.id - p.id
})
shuffle = function(o){ //v1.0for(var j, x, i = o.lengthij = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x)
return o
}
alert(shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))