Sorting by date in xsl file?

I’m getting a date feed which has a format “11/18/2011 12:00:00 PM” or “3/1/2011 10:00:00 AM”. As you can see in the format there are no leading zeros for the date.

How do I sort by date with this format?

This is what I have so far

<xsl:stylesheet xmlns:xsl="" version="1.0">

<xsl:param name="sortBy" select="'StartDate"/>
<xsl:param name="strXPath" select="//Activity"/>
<xsl:template match="/">    
  <xsl:apply-templates select="$strXPath">
    <xsl:sort select="*[name()=$sortBy]" order="ascending"/>

<xsl:template match="Activity">
   <td><xsl:value-of select="ActivityStartDateTime"/></td>
   <td><xsl:value-of select="Name"/></td>

Right now it is sorting by String. “11/13/2011 12:00:00 AM” comes before “2/25/2011 12:00:00 AM”. I trying to get “2/25/2011 12:00:00 AM” before “11/13/2011 12:00:00 AM”

Welcome to a special form of hell.

XSL doesn’t have a concept of datatypes in a conventional sense. Best bet would be to output the datetime values in a sortable manner if possible. The few times I’ve had to do this we actually spit out several datetimes – one for sorting (unix timestamp), one short display and one long dispalay. Extra fields beat the hell out of figuring out how to do it in XSL.