title: XSLT version 1.0, 'Select' then 'Store' into an Array then 'Sort' Array and Display Array
body: <p>I am a new to XSLT world. I was just wondering how Can I save my select result into an Array and sort that Array and then pick up my desirable index of array and display. After googling a bit about the problem I am able to use sort on a field. But I do not want to play inside with XML as it will be pretty long and complex rather I will prefer storing the result and then play around.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;catalog&gt;
      &lt;cd&gt;
          &lt;title&gt;Empire Burlesque&lt;/title&gt;
          &lt;artist&gt;Bob Dylan&lt;/artist&gt;
          &lt;country&gt;USA&lt;/country&gt;
          &lt;company&gt;Columbia&lt;/company&gt;
          &lt;price&gt;10.90&lt;/price&gt;
          &lt;year&gt;1985&lt;/year&gt;
                  &lt;date&gt;2023-01-01&lt;/date&gt;
      &lt;/cd&gt;
      &lt;cd&gt;
          &lt;title&gt;Hide your heart&lt;/title&gt;
          &lt;artist&gt;Bonnie Tyler&lt;/artist&gt;
          &lt;country&gt;UK&lt;/country&gt;
          &lt;company&gt;CBS Records&lt;/company&gt;
          &lt;price&gt;9.90&lt;/price&gt;
          &lt;year&gt;1988&lt;/year&gt;
                  &lt;date&gt;2022-01-01&lt;/date&gt;
      &lt;/cd&gt;
      &lt;cd&gt;
          &lt;title&gt;Greatest Hits&lt;/title&gt;
          &lt;artist&gt;Dolly Parton&lt;/artist&gt;
          &lt;country&gt;USA&lt;/country&gt;
          &lt;company&gt;RCA&lt;/company&gt;
          &lt;price&gt;9.90&lt;/price&gt;
          &lt;year&gt;1982&lt;/year&gt;
                  &lt;date&gt;2021-01-01&lt;/date&gt;
      &lt;/cd&gt;
  &lt;/catalog&gt;
  </code></pre>
  
  <p>XSLT:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:template match="/"&gt;
    &lt;html&gt;
    &lt;body&gt;
      &lt;h2&gt;My CD Collection&lt;/h2&gt;
      &lt;table border="1"&gt;
        &lt;tr bgcolor="#9acd32"&gt;
          &lt;th&gt;Title&lt;/th&gt;
          &lt;th&gt;Artist&lt;/th&gt;
          &lt;th&gt;Date&lt;/th&gt;
        &lt;/tr&gt;
        &lt;xsl:for-each select="catalog/cd"&gt;
        &lt;xsl:sort select="date"/&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;xsl:value-of select="title"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;xsl:value-of select="artist"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;xsl:value-of select="date"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;/xsl:for-each&gt;
      &lt;/table&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>So How can I collect all dates at one place and then sort them. Thanks</p>