function __format(data){
var tmp = {},lvIdArr = [];
for(i in data){
if(!lvIdArr[data.lv]){
lvIdArr[data.lv] = [];
}
lvIdArr[data.lv].push(data.id);
tmp[data.id] = data;
}
var dataArr = [],len = lvIdArr.length;
for(i = len;i >0;i–){
lvIdArr.forEach(function(id){
if(dataArr){
dataArr.child.push(tmp);
}else{
dataArr = tmp[tmp.pid];
dataArr.child = [];
}
});
}
return dataArr;
}
var data = ;
function __format(data){
var tmp = {},lvIdArr = [];
for(i in data){
if(!lvIdArr[data.lv]){
lvIdArr[data.lv] = [];
}
lvIdArr[data.lv].push(data.id);
tmp[data.id] = data;
}
var dataArr = [],len = lvIdArr.length;
for(i = len - 1;i >=0;–i){
(lvIdArr || []).forEach(function(id){
if(dataArr){
dataArr.child.push(tmp);
}else{
dataArr = tmp[tmp.pid] || tmp;
dataArr.child = [];
}
});
}
return dataArr;
}
__format(data);
var data = ;
function __format(data){
var tmp = {},lvIdArr = [];
for(i in data){
if(!lvIdArr[data.lv]){
lvIdArr[data.lv] = [];
}
lvIdArr[data.lv].push(data.id);
tmp[data.id] = data;
}
var dataArr = [],len = lvIdArr.length;
for(i = len - 1;i >=0;–i){
(lvIdArr || []).forEach(function(id){//item的id
if(i == 0){
dataArr.push(tmp);
}else{
if(!tmp[tmp.pid].child){
tmp[tmp.pid].child = [];
}
tmp[tmp.pid].child.push(tmp);
}
});
}
return dataArr;
}
__format(data);