日期:2014-05-16  浏览次数:20596 次

javascript分组(还算高效)
var arr =  [
        	['aaa',1,2,3],
        	['bbb',2,4,'c'],
        	['ccc',2,35,6],
        	['aaa',45,14,78],
        	['bbb',77,74,11],
        	['aaa',14,1425,14],
        	['ccc',14,14,18]
	      ];

var gro = {};

for(var i=0;i<arr.length;i++){
	if(gro[arr[i][0]]){
		gro[arr[i][0]].push(arr[i]);
	}else{
		gro[arr[i][0]] = [];
		gro[arr[i][0]].push(arr[i]);
	}
}

alert(JSON.stringify(gro));