Logic
Arrays
Data Types
Objects
function mapOrder(array, order, key) { if (!Array.isArray(array)) return []; const lookupTablea = array.reduceRight((table, o) => table.set(o[key], o), new Map()); return order.map(k => lookupTablea.get(k)); }
- function mapOrder(array, order, key) {
- if (!Array.isArray(array)) return [];
const lookupTable = array.reduceRight((table, o) => table.set(o[key], o), new Map());- const lookupTablea = array.reduceRight((table, o) => table.set(o[key], o), new Map());
return order.map(k => lookupTable.get(k));- return order.map(k => lookupTablea.get(k));
- }