title: xsl:sort with imperial measurements
body: <p>I’m trying to make an xslt file to sort a list for InDesign.</p>
  
  <p>The issue I’m having is trying to get the the list to sort as expected when the size is in imperial rather than metric. To complicate things a little more the size information is contained in a string.</p>
  
  <p>here’s the xslt:
      </p>
  
  <p>
    </p>
  
  <p></p>
  
  <pre><code>&lt;CATEGORY&gt;
    &lt;VERS&gt;
      &lt;xsl:for-each select="VFPData/g_otemp/prodid"&gt;
        &lt;xsl:sort select="floor(translate(../desc,$vDigits,''))" /&gt;
        &lt;xsl:sort select="translate(../desc,$vAlpha,'')" data-type="number"/&gt;
  
          &lt;xsl:if test="../inactive != 'true'"&gt;
            &lt;code&gt;&lt;xsl:value-of select="../prodid" /&gt;&lt;/code&gt;       
            &lt;name&gt;&lt;xsl:value-of select="../desc" /&gt;&lt;/name&gt;
            &lt;xsl:if test="../priceout != '0.0000'"&gt;
              &lt;price&gt;&lt;xsl:value-of select="format-number(../priceout, '£0.00')" /&gt;&lt;/price&gt;
            &lt;/xsl:if&gt;
            &lt;xsl:if test="../priceout = '0.0000'"&gt;
              &lt;price&gt;P.O.A&lt;/price&gt;
            &lt;/xsl:if&gt;
          &lt;/xsl:if&gt;
      &lt;/xsl:for-each&gt;
    &lt;/VERS&gt;
  &lt;/CATEGORY&gt;
  </code></pre>
  
  <p></p>
  
  <p>Which works fine when dealing with metric sizes, however with imperial you see sorting like this:</p>
  
  <pre><code>&lt;VERS&gt;
      &lt;code&gt;BM50-100&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 16" x 12" x 1"&lt;/name&gt;
      &lt;price&gt;£31.82&lt;/price&gt;
      &lt;code&gt;BM50-106&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 11" x 8 1/2" x 1"&lt;/name&gt;
      &lt;price&gt;£24.33&lt;/price&gt;
      &lt;code&gt;BM50-123&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 2 1/2" x 2" x 1/2"&lt;/name&gt;
      &lt;price&gt;£7.42&lt;/price&gt;
      &lt;code&gt;BM50-133&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 2 3/4" x 2" x 1/2"&lt;/name&gt;
  &lt;/VERS&gt;
  </code></pre>
  
  <p>Where it should be:</p>
  
  <pre><code>&lt;VERS&gt;
      &lt;code&gt;BM50-123&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 2 1/2" x 2" x 1/2"&lt;/name&gt;
      &lt;price&gt;£7.42&lt;/price&gt;
      &lt;code&gt;BM50-133&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 2 3/4" x 2" x 1/2"&lt;/name&gt;
      &lt;code&gt;BM50-106&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 11" x 8 1/2" x 1"&lt;/name&gt;
      &lt;price&gt;£24.33&lt;/price&gt;
      &lt;code&gt;BM50-100&lt;/code&gt;
      &lt;name&gt;Blue-Max Joint 16" x 12" x 1"&lt;/name&gt;
      &lt;price&gt;£31.82&lt;/price&gt;
  &lt;/VERS&gt;
  </code></pre>
  
  <p>Presumably this is happening because the value it's sorting by is the combination of all the numbers in the string, meaning that '2 3/4" x 2" x 1/2"' = 234212 making it indeed larger than '16" x 12" x 1"' (16121).</p>
  
  <p>I've tried to just isolate it to the first number (so between 'Joint ' and '"') and that only really worked if the first number didn't have a fraction.</p>
  
  <p>My other thought is would it be possible to have xslt convert the fraction to a decimal? </p>
  
  <p>How on earth would I go about sorting this using XSLT?</p>