Here is the basics of the schema... there is more than this, but this gives a good idea of what I need to accomplish:
<item>
<name>This is some product name to sort with dictionary sort.</name>
<price value="29.99">$29.99</price>
</item>
<item>
<name>This is some product name to sort with dictionary sort.</name>
<price value="29.99">$29.99</price>
</item>
Here is a down-and-dirty approach:
var node = null;
var path = null;
var items = jQuery( "item", xml );
var itemsTmp = new Array();
var itemsSorted = [];
for ( i = 0; i < items.length; i++ ) {
// price
itemsTmp[i] = jQuery( "price", items[i] ).attr( "value" );
}
itemsTmp.sort(function(a,b){return a-b});
for ( i=0;i<itemsTmp.length;i++ ) {
itemsSorted[ i ] = jQuery( "price[value=" + itemsTmp[ i ] + "]", items ).parent();
}
The problem is that itemsSorted is now an array of jQuery objects. I need to get all of my item nodes back together, but sorted, so that later I can do:
jQuery( "item", xml ).each(function() {
alert( jQuery( "price", this ).text() );
});