Сообщение от рони
|
Judgin,
<body>
<script>
const data = [{
'1': '123'
}, {
'ббб': '123'
}, {
'аа': '123'
}, {
'1аб': '123'
}, {
'22': '123'
}];
let order = 1;
const collator = new Intl.Collator(["en", "ru"], {
numeric: true
});
const comparator = (order) => (a, b) => order * collator.compare(
Object.keys(a)[0], Object.keys(b)[0]
);
data.sort(comparator(order))
document.body.append(JSON.stringify(data))
</script>
</body>
|
Не работает, у меня структура объекта другая.
const data = [{
'1': '123',
'ббб': '123',
'аа': '123',
'1аб': '123',
'22': '123',
}];