showing results for - "loadash sort by order of another array"
Aarón
11 May 2017
1var firstArray = ['asdf12','39342aa','12399','129asg',...];
2
3// a collection which has these keys in each object like so:
4var collection = [{guid: '39342aa', name: 'John'},{guid: '129asg', name: 'Mary'}, ... ];
5
6const last = collection.length;
7
8var sortedCollection = _.sortBy(collection, function(item){
9  return firstArray.indexOf(item.guid) !== -1
10  	? firstArray.indexOf(item.guid) : last;
11});
12