title: Sort XML nodes with jQuery and then join them
body: <p>Here is the basics of the schema... there is more than this, but this gives a good idea of what I need to accomplish:</p>
  
  <pre><code>&lt;item&gt;
      &lt;name&gt;This is some product name to sort with dictionary sort.&lt;/name&gt;
      &lt;price value="29.99"&gt;$29.99&lt;/price&gt;
  &lt;/item&gt;
  &lt;item&gt;
      &lt;name&gt;This is some product name to sort with dictionary sort.&lt;/name&gt;
      &lt;price value="29.99"&gt;$29.99&lt;/price&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>Here is a down-and-dirty approach:</p>
  
  <pre><code>var node = null;
  var path = null;
  var items = jQuery( "item", xml );
  var itemsTmp = new Array();
  var itemsSorted = [];
  
  for ( i = 0; i &lt; items.length; i++ ) {
  
      // price
      itemsTmp[i] = jQuery( "price", items[i] ).attr( "value" );
  
  }
  
  itemsTmp.sort(function(a,b){return a-b});
  
  for ( i=0;i&lt;itemsTmp.length;i++ ) {
  
      itemsSorted[ i ] = jQuery( "price[value=" + itemsTmp[ i ] + "]", items ).parent();
  
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>jQuery( "item", xml ).each(function() {
      alert( jQuery( "price", this ).text() );
  });
  </code></pre>