Well unless every element has the exact same attribute name you wouldn't usually put sorting inside an identity template.
xsl:sort goes within either a xsl:for-each or a xsl:apply-templates, so you have to be sorting from outside the elements you are sorting. Your identity would look like this:
Code:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()">
<xsl:sort select="@a"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>