Open qappleh opened 3 years ago
function test (arr) { let resultMap = new Map(); arr.forEach((item, index) => { if (!resultMap.has(item)) { resultMap.set(item, []); } resultMap.get(item).push(index) }) return [...resultMap].sort((a, b) => (b[1].length - a[1].length)); }