• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

order-by

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it worked, Thanks for the help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!