const data = [];
const random = (min, max) => Math.floor(Math.random() * (max - min)) + min;
for (let i = 0; i < 10000; i++) {
data.push({ x: random(1, 1000000) });
}
console.time("sort");
const sortData = data.sort( (a,b) => b.x - a.x);
console.timeEnd("sort");
console.log(sortData.filter(i => i.x === sortData[0].x));
console.time("map");
const mapData = data.map(i => i.x);
const maxData = Math.max(...mapData);
console.timeEnd("map");
console.log(mapData.filter(i => i === maxData));