Lodash sort collection based on external array

前端 未结 5 696
名媛妹妹
名媛妹妹 2020-12-30 21:01

I have an array with keys like so:

[\'asdf12\',\'39342aa\',\'12399\',\'129asg\',...] 

and a collection which has these keys in each object

5条回答
  •  有刺的猬
    2020-12-30 21:34

    var sortedCollection = _.sortBy(collection, function(item){
      return firstArray.indexOf(item.guid)
    });
    

提交回复
热议问题