title: Sorting multiple XML elements within a node, by attribute
body: <p>I've tried several of the solutions that I've found here, but none seem to work on the model that I'm using.  In my example XML, I'm trying to sort the mixed up chapters, into their proper sequence.</p>
  
  <p>Source XML:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;  
  &lt;library&gt;  
      &lt;book&gt;  
          &lt;title&gt;A Fascinating Tale&lt;/title&gt;  
          &lt;chapter num="4"&gt;
              &lt;text&gt;...and rambles to the end.&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="2"&gt;  
              &lt;text&gt;The hero would...&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="3"&gt;  
              &lt;text&gt;This went rambling on...&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="1"&gt;  
              &lt;text&gt;Once upon a time...&lt;/text&gt;  
          &lt;/chapter&gt;  
      &lt;/book&gt;  
  &lt;/library&gt;  
  </code></pre>
  
  <p>Should result in:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;  
  &lt;library&gt;  
      &lt;book&gt;  
          &lt;title&gt;A Fascinating Tale&lt;/title&gt;  
          &lt;chapter num="1"&gt;  
              &lt;text&gt;Once upon a time...&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="2"&gt;  
              &lt;text&gt;The hero would...&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="3"&gt;  
              &lt;text&gt;This went rambling on...&lt;/text&gt;  
          &lt;/chapter&gt;  
          &lt;chapter num="4"&gt;  
              &lt;text&gt;...and rambles to the end.&lt;/text&gt;  
          &lt;/chapter&gt;  
      &lt;/book&gt;  
  &lt;/library&gt;  
  </code></pre>
  
  <p>So from the stylesheet solutions I've found here, I can't get any to work.  Am I making this too difficult?  It seems like it should be fairly straightforward.</p>