日期:2014-05-16 浏览次数:20386 次
var j1 = [{id:'1001',name:'a'},{id:'1002',name:'b'},{id:'1003',name:'c'}]; var ids = "1003,1001,1002"; function getResultByOrder(array,order) { var result = []; for(var k=0;k<order.split(",").length;k++) { for(var i=0;i<array.length;i++) { if(array[i].id==order.split(",")[k]) { result[result.length] = array[i]; break; } } } return result; } //调用即可 getResultByOrder(j1,ids)