dimas15,
const collator = new Intl.Collator(["ru", "en"], {
numeric: true
});
let arr = obj.slice(0).sort((a, b) => {
let numA = (/^\d+/).test(a.name),
numB = (/^\d+/).test(b.name);
if (numA && !numB) return 1;
if (!numA && numB) return -1;
return collator.compare(
a.name,
b.name
)
}
);
const modmas = [];
let temp = {};
for (const el of arr) {
const first = el.name[0].toUpperCase();
if (temp.first != first) {
temp = {
first,
data: []
};
modmas.push(temp)
};
temp.data.push(el)
}
console.log(modmas);
const keys = modmas.map(({first}) => first);
console.log(keys);