You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by LANTRES Franck <Fr...@fr.renault-sport-f1.com> on 2005/10/11 09:56:51 UTC

xtags:forEach - integer sorting

Hi,

In a JSP, I use the xtags:forEach element and I would like to sort
elements in descending order according to an integer value.

If the XML source is :
<foo>
...
<list>
<value>2</value>
<value>4</value>
<value>6</value>
<value>56</value>
</list>
</foo>

And if I write :
<xtags:forEach select="/foo/list" sort="value" ascending="false"/>

The result I get is :
6
56
4
2
But I expect :
56
6
4
2

How can I do that ?

Thanks for your help.

Franck

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: xtags:forEach - integer sorting

Posted by Oded Arbel <od...@m-wise.com>.
On Tuesday, 11 בOctober 2005 09:56, LANTRES Franck wrote:
> Hi,
>
> In a JSP, I use the xtags:forEach element and I would like to sort
> elements in descending order according to an integer value.

> And if I write :
> <xtags:forEach select="/foo/list" sort="value" ascending="false"/>
>
> The result I get is :
> 6
> 56
> 4
> 2

Which is reasonable, as forEach does string sorting. You might want to 
either pad numbers with zeros or white space, or sort them yourself 
somehow.

-- 
Oded Arbel
m-Wise mobile solutions
oded@m-wise.com

+972-9-9611212 (204)
+972-54-7340014

::..
Never express yourself more clearly than you think. 
	-- N. Bohr

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org