title: xsl:sort with apply-templates not sorting
body: <p>I have quite a large XSL document for an assignment that does a number of things. It is nearly complete but I missed a requirement that it has to be sorted and I cannot get it working. Here is a SSCCE of what is happening.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;!--   Root Document    --&gt;
  &lt;xsl:template match="/"&gt;
  
      &lt;html&gt;
      &lt;body&gt;
  
          &lt;xsl:apply-templates select="staff"&gt;
              &lt;xsl:sort select="member/last_name" /&gt;
          &lt;/xsl:apply-templates&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="member"&gt;
      &lt;xsl:value-of select="first_name" /&gt;&amp;#160;&lt;xsl:value-of select="last_name" /&gt; &lt;br/&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The XML file looks like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?xml-stylesheet type="text/xsl" href="sort.xsl"?&gt;
  
  &lt;staff&gt;
      &lt;member&gt;
          &lt;first_name&gt;Joe&lt;/first_name&gt;
          &lt;last_name&gt;Blogs&lt;/last_name&gt;
      &lt;/member&gt;
  
      &lt;member&gt;
          &lt;first_name&gt;John&lt;/first_name&gt;
          &lt;last_name&gt;Smith&lt;/last_name&gt;
      &lt;/member&gt;
  
      &lt;member&gt;
          &lt;first_name&gt;Steven&lt;/first_name&gt;
          &lt;last_name&gt;Adams&lt;/last_name&gt;
      &lt;/member&gt;
  
  &lt;/staff&gt;
  </code></pre>
  
  <p>I was expecting the staff members to be listed by last name but they are not getting sorted. Please bear in mind that I am very inexperienced at XSLT.</p>