I use the following JS code for a map using the Google Maps API. I want to alphabetically sort the results. Right now, they just come out in order that they are in the XML file.
[code]
var request = GXmlHttp.create();
request.open(“GET”, “locations.xml”, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName(“marker”);
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute(“lat”));
var lng = parseFloat(markers[i].getAttribute(“lng”));
var point = new GLatLng(lat,lng);
var label = markers[i].getAttribute(“label”);
var html = “<span class=’windowTitle’>” + label + “</span><p class=’window’>” + GXml.value(markers[i].getElementsByTagName(“infowindow”)[0]) + “</p>”;
// create the marker
var marker = createMarker(point,label,html);
map.addOverlay(marker);
}
// put the assembled sidebar_html contents into the sidebar div
document.getElementById(“sidebar”).innerHTML = sidebar_html;
}
}
request.send(null);
}
The for loop just iterates though the file in order. How would I go about alphabetizing the results?