Marson,
спасибо Malleys, взято тут
https://javascript.ru/forum/misc/758...tml#post498107
<script>
function byField(field, order) {
var collator = new Intl.Collator(["en", "ru"], {
numeric: true
});
order = order ? 1 : -1;
return function(a, b) {
return order * collator.compare(a[field], b[field])
};
}
var users = [{
name: "Вася",
surname: 'Иванов',
age: 20
}, {
name: "Петя",
surname: 'Чапаев',
age: 25
}, {
name: "Маша",
surname: 'Медведева',
age: 18
}];
users.sort(byField('age', true));
users.forEach(function(user) {
console.log(user.age);
});
</script>