比如a是的你的数组 然后根据a数组里面每个对象的id属性排序:
var a = []
a.sort(function (o, p) {
return o.id - p.id
})
function shuffle(array) {var currentIndex = array.length
, temporaryValue
, randomIndex
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex)
currentIndex -= 1
temporaryValue = array[currentIndex]
array[currentIndex] = array[randomIndex]
array[randomIndex] = temporaryValue
}
return array
}