title: Sorting elements in XSLT 2.0
body: <p>I am trying to sort the following XML using XSLT</p>
  
  <pre><code>&lt;Name&gt;name3&lt;/Name&gt;
  &lt;Job&gt;x&lt;/Job&gt; 
  &lt;Name&gt;name1&lt;/Name&gt;
  &lt;Job&gt;y&lt;/Job&gt; 
  &lt;Name&gt;name2&lt;/Name&gt;
  </code></pre>
  
  <p>The expected output is</p>
  
  <pre><code>&lt;Name&gt;name1&lt;/Name&gt;
  &lt;Job&gt;x&lt;/Job&gt; 
  &lt;Name&gt;name2&lt;/Name&gt;
  &lt;Job&gt;y&lt;/Job&gt; 
  &lt;Name&gt;name3&lt;/Name&gt;
  </code></pre>
  
  <p>The Name elements have to be sorted while keeping the Job elements intact.
  I am using XSLT 2.0</p>
  
  <p>Although I am able to sort the Name elements properly using xsl:sort as given in the <a href="http://www.w3schools.com/xsl/el_sort.asp" rel="nofollow">tutorial</a>, the output I get is as follows:</p>
  
  <pre><code>&lt;Name&gt;name1&lt;/Name&gt;
  &lt;Name&gt;name2&lt;/Name&gt;
  &lt;Name&gt;name3&lt;/Name&gt;
  &lt;Name&gt;name3&lt;/Name&gt;
  &lt;Job&gt;x&lt;/Job&gt; 
  &lt;Name&gt;name1&lt;/Name&gt;
  &lt;Job&gt;y&lt;/Job&gt; 
  &lt;Name&gt;name2&lt;/Name&gt;
  </code></pre>
  
  <p>I am new to XSLT. Sorry, if this is a very simple question. 
  Thanks in advance.</p>