【发布时间】:2019-06-10 16:21:47
【问题描述】:
使用 Lodash,我将如何根据给定的包含值的排序数组对对象数组进行排序?
例如,给定:
const movies = [
{
title: "La La Land",
genre: "Musical"
},
{
title: "Avengers",
genre: "Action"
},
{
title: "Chucky",
genre: "Horror"
}
]
const titles = [
"Chucky",
"La La Land",
"Avengers"
]
我如何获得:
const sortedMovies = [
{
title: "Chucky",
genre: "Horror"
},
{
title: "La La Land",
genre: "Musical"
},
{
title: "Avengers",
genre: "Action"
}
]
哪个是按照titles数组中电影片名的排序顺序排序的?
【问题讨论】:
标签: javascript ecmascript-6 lodash