I want to convert an Array of Arrays to one object with the same sort in javascript. My problem is the keys are in numbers and i just sorted the values as i want but when i convert the array to object by useing reduce it sort it again by keys.
const names = {
1: 'ياسر',
3: 'احمد'
}
const sorting = Object.entries(names)
.sort((a, b) => a[1].localeCompare(b[1], "ar", { ignorePunctuation: true }))
.reduce((acc, x) {
acc[x[0]] = x[1];
return acc;
}, {});