In XSLT, with xsl:sort, if the sort key computed using the select expression is numeric (for example @length*@width), but the data type is explicitly set to text, an error is reported
XTDE1030: Non-comparable types found while sorting: net.sf.saxon.value.StringValue cannot be cast to net.sf.saxon.value.NumericValue
The correct behaviour is to convert the sort keys to strings and compare them as strings.
This bug is present in all known releases. A new test case sort145 has been created and submitted to the W3C test suite.
A patch is being committed to Subversion on the 9.1 branch.