现在有四个list,每个list都含有若干对象,对象都含有时间属性,其他属性不同,如何根据时间属性将四个list合并在一起,空间复杂度低一点的方法
const list = [...list1,...list2,...list3,...list4];
function compare(property){
return function(a,b){
var value1 = a[property];
var value2 = b[property];
return value1 - value2;
}
}
console.log(list.sort(compare('date')))
是把四个list合并成一个list对象吗
而且时间的值并不是相同的,只是有序,合并后的list中的时间要是有序的
当前list通过push方法 合并其他 List 然后通过JS的sort来实现排序操作