【发布时间】:2020-07-03 16:22:38
【问题描述】:
sortedArray = [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
unSortedArray = [{id: 8, text : 'abcd'}, {id: 4, text : 'ab'}, {id: 1, text : 'cd'}, {id: 2, text : 'def'}, {id: 3, text : 'abcd'}, {id: 5, text : 'abcd'}]
我想根据sortedArray 的项目对unSortedArray 进行排序,并且只想要与sortedArray 中具有相同ID 的对象
预期结果
[{id: 1, text : 'cd'}, {id: 2, text : 'def'}, {id: 3, text : 'abcd'}, {id: 4, text : 'abc'}]
我根据类似的问题尝试了类似的建议。 添加此类问题的链接here
【问题讨论】:
-
到目前为止你尝试了什么?
标签: javascript ecmascript-6 lodash