Displaying array elements in order

P

Pragash Mr.

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
 
M

Mikael Høilund

a=3D[12,354,633,68,85]
<%for i in a%>
<%z=3DDocument.find(i)%>
<%=3Dz.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` =20
construct. Arrays are inherently ordered, so using a `for` will always =20=

yield the elements in the order they appear in the array. Try =20
inspecting the array before looping over it to see which order the =20
elements are in.

--=20
Mikael H=F8ilund
http://hoilund.org/
 
P

Pragash Mr.

Mikael said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top