I have the following JS function to make an AJAX call to my PHP file which contains a geojson with 175 countries.
Each of these country names and codes are appended to my nav bar drop-down list
$(document).ready(() => {
if ("geolocation" in navigator) {
const geoLocation = navigator.geolocation.getCurrentPosition((position) => {
map.panTo(new L.LatLng(position["coords"]["latitude"], position["coords"]["longitude"], ))
});
}
$.ajax({
url: "assets/php/getcountryList.php",
type: "GET",
dataType: "json",
data: {},
success: function(result) {
console.log(result)
for (var i = 0; i < result.data.border.features.length; i++) {
$('#innerSelect').append("<option value=" + result.data.border.features[i].properties.iso_a2 + ">" + result.data.border.features[i].properties.name + "</option>");
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
}
})
addCountryBorder();
})
However, currently they're unordered. How can I list in the dropdown alphabetically?