# Import/sort XML into alphabetical order?

**URL:** <https://forum.kirupa.com/t/import-sort-xml-into-alphabetical-order/315918>\
**Category:** flash\
**Created:** [November 7, 2010, 9:51pm UTC](https://forum.kirupa.com/t/import-sort-xml-into-alphabetical-order/315918 "2010-11-07T21:51:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kappa](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Kappa](https://forum.kirupa.com/u/Kappa)\
**Post date:** [November 7, 2010, 9:51pm UTC](https://forum.kirupa.com/t/import-sort-xml-into-alphabetical-order/315918/1 "2010-11-07T21:51:09Z")

</div>

I’m using this code below to load xml data and display it in text fields, I was wondering if there was a way to load them in alphabetical order, based on the nodeValue of **name**?

```auto
stop();

function loadXML(true) {
	if (true) {
		xmlNode = this.firstChild;
		name = [];
		donation = [];
		message = [];
		attachLight();
	} else {
		trace("file not loaded!");
	}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("lights.xml");

function attachLight() {

total = (xmlNode.childNodes.length);
//For loop to attach our container movieclip and pass the xml information
var xPos = 0;
var yPos = 0; 

for(i=0;i<total;i++){

//define xml
**name*** = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
[COLOR="DarkOrange"]// need to somehow sort this value alphabetically[/COLOR]
donation* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
message* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;

//attach container clip
currMovie = attachMovie("light", "xml"+i, i, {_x:xPos, _y:yPos});

xPos += currMovie._width - 250;

//add text to text boxes
currMovie.name_txt.text = name*;
currMovie.donation_txt.text = "$" + donation*;
currMovie.message_txt.text = message*;

}

```
