This is a mini library, it was pretty handy to me , imagine this there is a certain sub array you have and then you want the sub array to have the same order as the parent does,
Example,
var parent = [1,2,3,4,5,6,7,8,9];
var sub = [8,2,1,6,4];
To achieve this you simply call
var newArr = getOrderedArray(parent, sub);
Which will give you [1,2,4,6,8]
And to get the reverse of this simply add one more parameter to it, and set it to true
yarn add sub-array-order
const getOrderedArray = require('sub-array-order');
getOrderedArray([1,2,3,4,5,6,7,8,9,10], [8,3,4,1]);
[ 1, 3, 4, 8 ]
getOrderedArray([1,2,3,4,5,6,7,8,9,10], [8,3,4,1], true);
[ 8, 4, 3, 1 ]