Displaying array elements in order

Hi,

for example

a=[12,354,633,68,85]
<%for i in a%>
<%z=Document.find(i)%>
<%=z.name%>
<%end%>

Here the result is displaying randomly in browser
but i want to display the result in the array order
i.e first 12 then followed by 354,633,68,85

If you have any solution plz reply

On Jul 15, 2008, at 11:28, Pragash Mr. wrote:

a=[12,354,633,68,85]
<%for i in a%>
<%z=Document.find(i)%>
<%=z.name%>
<%end%>

Here the result is displaying randomly in browser
but i want to display the result in the array order
i.e first 12 then followed by 354,633,68,85

If that’s happening, the array is ordered randomly before the for
construct. Arrays are inherently ordered, so using a for will always
yield the elements in the order they appear in the array. Try
inspecting the array before looping over it to see which order the
elements are in.

Mikael Høilund wrote:

On Jul 15, 2008, at 11:28, Pragash Mr. wrote:

a=[12,354,633,68,85]
<%for i in a%>
<%z=Document.find(i)%>
<%=z.name%>
<%end%>

Here the result is displaying randomly in browser
but i want to display the result in the array order
i.e first 12 then followed by 354,633,68,85

If that’s happening, the array is ordered randomly before the for
construct. Arrays are inherently ordered, so using a for will always
yield the elements in the order they appear in the array. Try
inspecting the array before looping over it to see which order the
elements are in.

Hi,
Before the for loop also i checked but it is displaying in random order
even though aray order is [12,354,633,68,85]
but i have one doubt if it is ajax call then it will display in random
order… plz reply