Here is how we can sort in given XML using XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="Records">
<xsl:apply-templates>
<!-- year part -->
<xsl:sort select="substring-after(substring-after(@OrderDate,'/'),'/')" />
<!-- month part -->
<xsl:sort select="substring-before(substring-after(@OrderDate,'/'),'/')" />
<!-- day part -->
<xsl:sort select="substring-before(@OrderDate,'/')" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Order">
<xsl:if test="position() = 1">
<xsl:value-of select="@OrderDate"/> <br/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
To test the functionality use the following Sample XML. Use the below Url to test http://www.w3schools.com/Xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog
<root>
<Records>
<Order OrderDate="14/01/2011"> </Order>
<Order OrderDate="05/01/2011"> </Order>
<Order OrderDate="08/01/2011"> </Order>
<Order OrderDate="10/01/2011"> </Order>
</Records>
</root>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="Records">
<xsl:apply-templates>
<!-- year part -->
<xsl:sort select="substring-after(substring-after(@OrderDate,'/'),'/')" />
<!-- month part -->
<xsl:sort select="substring-before(substring-after(@OrderDate,'/'),'/')" />
<!-- day part -->
<xsl:sort select="substring-before(@OrderDate,'/')" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Order">
<xsl:if test="position() = 1">
<xsl:value-of select="@OrderDate"/> <br/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
To test the functionality use the following Sample XML. Use the below Url to test http://www.w3schools.com/Xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog
<root>
<Records>
<Order OrderDate="14/01/2011"> </Order>
<Order OrderDate="05/01/2011"> </Order>
<Order OrderDate="08/01/2011"> </Order>
<Order OrderDate="10/01/2011"> </Order>
</Records>
</root>