This is my array of object
[{"name":"Tania","country":"BR"},{"name":"Carl","country":"BR"},{"name":"Farl","country":"BR"},{"name":"Rany","country":"BR"},{"name":"Ron","country":"JP"},{"name":"Antony","country":"JP"}]
I want to sort this array by name and same country. This is the result
[{"name":"Carl","country":"BR"},{"name":"Farl","country":"BR"},{"name":"Rany","country":"BR"},{"name":"Tania","country":"BR"},{"name":"Antony","country":"JP"},{"name":"Ron","country":"JP"}]
To make the sort only for the name I make this, but in this case is not divided by country, how can I do this?
array.sort((f , n)=> {
var nameF = f.name.toUpperCase();
var nameN = n.name.toUpperCase();
if(nameF < nameN) return -1;
else if(nameF > nameN) return 1;
else return 0
});