Here is my snippet which has names in Arabic (i.e I want to show some data for Saudi Arabia)
I have tried local compare()
method but doesn't work
let arr = [{
"id": "4231a075-ac9d-4c58-b6c2-2d4cf73d72e1",
"name": "النَّشاطُ الثّالِثُ - وَرْشَةُ الْكِتابَةِ 2",
"author": "na",
"countryCode": "SA",
"createdAt": "2019-10-06T07:30:16.770Z",
"pageId": "188"
},
{
"id": "fde7d816-4eb8-4c82-a875-23hsd",
"name": "النَّشاطُ الثّاني - وَرْشَةُ الْكِتابَةِ 1",
"author": "na",
"countryCode": "SA",
"createdAt": "2019-10-06T07:30:16.770Z",
"pageId": "188"
}
]
arr.sort(function(a, b) {
return a.pageId - b.pageId || a.name.localeCompare(b.name, ["ar"]);
});
console.log(arr)