permaculture playing cards*
The moose likes XML and Related Technologies and the fly likes order-by Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "order-by" Watch "order-by" New topic
Author

order-by

Ahmed Haboubi
Ranch Hand

Joined: Oct 21, 2000
Posts: 36
When using the order-by parameter in the for-each instruction on numbers, the result is unexpected. For example, you may get the following sorting:
12
5
81
9
It seems like order-by is not treating them as numbers, but rather as text. What is the solution for this?
Thanking you in advance.
Scott Collens
Greenhorn

Joined: Jun 21, 2001
Posts: 20
You are correct.
The result of the evaluation expression is always converted to a string. Therefore it looks at the first digit in the number for its first filter, then the second and so on. To order the numbers properly you must set the data-type attribute to number.
<xsl:sort select="expression" data-type="number" order="ascending"/>
Ahmed Haboubi
Ranch Hand

Joined: Oct 21, 2000
Posts: 36
Yes, it worked, Thanks for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: order-by
 
Similar Threads
Thread Question
Tree Question
random number generation
Simple program: NEED HELP!!
A number game