Sorry about the title, I'm really not sure how to word this. I'm stuck, I need to sort an array by its object's title property value, into the same order of a second array of strings.
Basically, I have two arrays...
var titles = [
'title1',
'title2',
'title3',
'title4',
'title5'
]
var objects = [
{
title: 'title5',
...//other values
}, {
title: 'title3',
...//other values
}
, {
title: 'title4',
...//other values
}, {
title: 'title1',
...//other values
}, {
title: 'title2',
...//other values
}
]
I want to order the objects array in the same order as the strings in titles array. Is this possible? My code base has access to _underscore, or I can use plain ES6.
sort()them on base of their last number?