This is a very strange issue.
I am calling a server side method to return an array of suburbs which have been sorted alphabetically.
When I hit the end-point directly, the order is as expected. However, when Jquery calls the method, it is returned in a random order...
I suspect the issue is to do with the jquery function:
function updateSuburbs(suburb_selected,town_id)
{
var $suburbs = $("#mds_suburbs");
$suburbs.empty();
$suburbs.append($("<option></option>").attr("value", "").text('Loading...'));
url = '/api/rpc/delivery/engine/suburbs/town_id/' + town_id;
$.ajax({
type: 'GET',
async: true,
url: url,
dataType: "json",
success: function(responseObject){
$suburbs.empty();
$suburbs.append($("<option></option>").attr("value", "").text('Select your suburb'));
if (responseObject.status) {
if (responseObject.suburbs) {
$.each(responseObject.suburbs, function(value,key) {
$suburbs.append($("<option></option>").attr("value", value).text(key));
});
if (suburb_selected !== null && suburb_selected !== '')
{
$('#mds_suburbs').val(suburb_selected);
}
} else {
$suburbs.append($("<option></option>")
.attr("value", 0).text('No suburbs for this town...'));
}
} else {
$suburbs.empty();
$suburbs.append($("<option></option>").attr("value", "").text('Error locations suburb'));
}
}
});
}
EIDT:
Further reading and research suggests that it is infact Chrome that is automatically sorting the object array... :S
Server side output:
Client side output:

