ok - I do understand that the sorting in associative arrays is implementation
specific

but what alternative do I have to the "for .. in" loop. How can I step through
all elements of an associative array withouth using "for .. in"

Or should I avoid using associative arrays at all? Would be bad news. I am quite
used to associative arrays, coming from perl/PHP

apologize if that is a stupid question. I am not a good programmer ...

Thanks for ideas on that issue,
Andreas


Zitiere Jim Ley <[EMAIL PROTECTED]>:

> 
> "Andreas Neumann" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> > Later on I use a "for ... in" loop to extract the values of the
> associative
> > array.
> 
> This isn't really safe, because things in the prototype also can get
> enumerated so if I do:
> 
> Array.prototype.chicken=function() {alert('a') }
> 
> n=[]
> n['a']=1
> 
> for (i in n) alert(i)
> 
> will alert a and chicken
> 
> > It appears that the Rhino js engine automatically sorts
> alphabetically
> > according to the index value, which means, that "Asians" come first,
> then
> "
> > Blacks", ....
> 
> Perfectly valid behaviour, there's no reliability on the ordering, it's
> implementation specific, I'd recommend rewriting to avoid needing for i
> in a
> syntax.
> 
> Jim.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



--     
The only thing that stands between a man and what he wants from
life is often merely the will to try it and the faith to believe
that it is possible ...
-- M. DeVos
    
----------------------------------------------     
Andreas Neumann - Department of Cartography     
Swiss Federal Institute of Technology (ETH)     
ETH Hoenggerberg, CH-8093  Zurich, Switzerland     
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153     
e-mail: [EMAIL PROTECTED]     
www: http://www.karto.ethz.ch/neumann/     
SVG.Open/Carto.net: http://www.svgopen.org/     

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to