The server returns the following response from a query:
{ ROM: "Romania",
YUG: "Yugoslavia",
PRT: "Portugal",
MKD: "Macedonia",
GRC: "Greece",
FRA: "France",
ISL: "Iceland",
LUX: "Luxembourg",
HUN: "Hungary",
GBR: "United Kingdom", 36 more… }
I need to put these into an already existing select like so:
$.each(result, function(key, value) {
$('#country')
.append($("<option></option>")
.attr("value",key)
.text(value));
});
Can someone tell me how to sort the countries alphabetically by value before inserting them into the html element?