Код: Выделить всё
const jsonArray = Array.from({ length: 100000 }, (_, i) => ({
id: i,
principle: Math.random() * 1000,
interest: Math.random() * 1000,
maturity: Math.random() * 1000,
maturity_date: new Date(Date.now() + Math.random() * 100000000).toISOString(),
maturity_amount: Math.random() * 1000,
maturity_amount_date: new Date(Date.now() + Math.random() * 100000000).toISOString(),
maturity_amount_value: Math.random() * 1000,
maturity_amount_date_value: Math.random() * 1000,
maturity_amount_date_value_date: new Date(Date.now() + Math.random() * 100000000).toISOString(),
maturity_amount_date_value_name: `Name ${Math.random() * 100000}`,
maturity_amount_date_value_name_date: new Date(Date.now() + Math.random() * 100000000).toISOString(),
maturity_amount_date_value_name_date_value: Math.random() * 1000,
name: `Name ${Math.random() * 100000}`,
value: Math.random() * 1000,
}));
//console.log(jsonArray);
console.time('Sort time');
const sortedArray = jsonArray.sort((a, b) => a.name.localeCompare(b.name)); // Sort by 'name' in ascending order
console.timeEnd('Sort time');
Подробнее здесь: https://stackoverflow.com/questions/795 ... -size-json