Vlasenko Fedor,
let arr1 = [1.58, 0.12, 0.1, 0.06, 0.06, 0.06, 0.05, 0.05, 0.05, 0.05, 0.05, 0.01];
let arr2 = [0.05, 0.1, 0.06, 0.06, 0.05, 0.05, 0.05, 0.01, 1.58];
function arrIndex(a, b) {
let ob = {};
return b.reduce((ar, el) => {
let k = ob[el] ??= 0;
k = a.indexOf(el, k);
ar.push(k);
ob[el] = ++k;
return ar;
}, [])
}
const res = arr2.map(v => this.i = arr1.indexOf(v, ++this.i % arr1.length), {i: -1})
console.log(res);
console.log(arrIndex(arr1, arr2));