const arr = [
{
id: 1,
name: 'Alexey',
value: 100
},
{
id: 2,
name: 'Yuri',
value: 400
},
{
id: 3,
name: 'Ruslan',
value: 500
},
{
id: 4,
name: 'Mikhail',
value: 10000
}
]
const compare = (a, b) => {
if (a === b) return 0;
return a < b ? -1 : 1;
};
arr.sort((a, b) => {
return a.name === b.name ? compare(a.value, b.value) : compare(a.name, b.name);
})
arr.sort((a, b) => {
if (a.name === b.name) return a.value - b.value;
return (a.name > b.name) ? 1 : -1;
});