I have an array of currencies [\"GBP\", \"EUR\", \"NOK\", \"DKK\", \"SKE\", \"USD\", \"SEK\", \"BGN\"]. I would like to order it by moving predefined list if th
I guess this can also be achieved like this
Array.prototype.intersect = function(a) {
return this.filter(e => a.includes(e));
};
Array.prototype.excludes = function(a) {
return this.filter(e => !a.includes(e));
};
var getCur = (p,c) => p.intersect(c).concat(c.excludes(p)),
cur1 = ["GBP", "EUR", "NOK", "DKK", "SKE", "USD", "SEK", "BGN"],
cur2 = ["GBP", "EUR", "NOK", "LTU", "ZGN"],
pdl = ['EUR', 'USD', 'DKK', 'SKE', 'NOK', 'GBP', 'SEK', 'BGN'];
console.log(getCur(pdl,cur1));
console.log(getCur(pdl,cur2));