Sorting XML-fed Data in Flash

With regard to this tutorial…
http://www.kirupa.com/web/xml/examples/sortedgradeslist.htm

…it’s great for sorting XML data if your data is structured like this:


<?xml version="1.0" ?>
<grades>
<student first="James" last="Johnson" gpa="3.3" /> 
<student first="John" last="Smith" gpa="4.0" /> 
<student first="Serena" last="Williams" gpa="3.8" /> 
<student first="Indiana" last="Jones" gpa="3.2" /> 
<student first="Linda" last="Brown" gpa="3.9" /> 
<student first="Robert" last="Davis" gpa="3.2" /> 
<student first="Seno" last="Cular" gpa="4.0" /> 
<student first="Mike" last="Wilson" gpa="3.0" /> 
<student first="Mary" last="Moore" gpa="3.0" /> 
<student first="Will" last="Taylor" gpa="2.5" /> 
<student first="Thomas" last="Anderson" gpa="2.1" /> 
<student first="David" last="Thomas" gpa="3.7" />
</grades>

…but what I’m looking for is a way to sort XML data fed into Flash when the data is structured like this, for example:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/kresge.jpg</image>
		<caption>Kresge</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/medialab.jpg</image>
		<caption>Media Lab</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/stata.jpg</image>
		<caption>Stata Center</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/stata_lobby.jpg</image>
		<caption>Stata Lobby</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/construction.jpg</image>
		<caption>Construction</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/dome.jpg</image>
		<caption>The Dome</caption>
	</pic>
	<pic>
		<image>http://www.kirupa.com/developer/mx2004/pg/structure.jpg</image>
		<caption>Structure</caption>
	</pic>
</images>

Is there some way of using sort or sortOn to tell Flash you want to sort the data by a certain thing, like if I wanted to sort alphabetically by the image caption in the example above? Can anyone direct me towards a tutorial on something like this?

[size=1]Purpose: I’m loading data from XML into an index using attachMovie to dynamically create the index items which are all buttons. The index buttons contain item details that I want the user to be able to sort by.[/size]

[size=1]The reason why I’ve structured the XML the way I have rather than the way in the tutorial above is because I’m making this for someone else with little XML knowledge and it would be easier for them to edit the data in a program like XML Notepad if the data was structured the way I have structured it.[/size]

Thanks very much in advance for any help you can give!! :slight_smile: