function compare(fArr,arr) {
var search = arr.slice(),
insert = [],
remove = [],
replace = [];
for(var i = 0, index; i < fArr.length; i++) {
if(fArr[i] === arr[i]){
search[i] = undefined;
continue;
}
index = search.indexOf(fArr[i]);
if(!~index) {
remove.push(i);
continue;
}
i != index && replace.push({old: i, new: index});
search[index] = undefined;
};
search.forEach(function (elem, i) {
if(elem !== undefined)
insert.push(i);
});
return {
remove: remove,
insert: insert,
replace: replace
}
}