After reading through the documentation
It seems that utilizing the sort method instead of filter would be more appropriate for your situation.
var items = [
{ name: "Edward", value: 21 },
{ name: "Sharpe", value: 37 },
{ name: "And", value: 45 },
{ name: "The", value: -12 },
{ name: "Magnetic", value: 13 },
{ name: "Zeros", value: 37 }
];
items.sort(function (a, b) {
return a.value - b.value;
});
For your specific scenario, the following could be effective:
loadCountries() {
return require("country-data")
.countries.all.sort((a, b) => a.name - b.name)
.map(country => ({
label: country.name,
value: country.alpha3
}));
}
Additionally, another option is to utilize localeCompare
loadCountries() {
return require("country-data")
.countries.all.sort((a, b) => a.name.localeCompare(b.name))
.map(country => ({
label: country.name,
value: country.alpha3
}));
}