> > Of course, coldfusion has to loop over the keys a certain > > way. It does it alphabetically, but that is just the way > > it is done. If they do it some other way in MX, you can't > > complain because structures are NOT ordered. > > Pascal. why does Coldfusion have to loop over the keys in a > certain way? The easiest way would be to display them in the > order that they are entered into the structure, not going out > of its way to order them alphabetically, which, incidentally, > is exactly what its doing. > > I just had a play with Mark's code and for whatever reason, > whether you return the key list, cfdump the struct variable > or loop through the collection, the list of keys always returns > in alphabetic order.
I think what Pascal was trying to convey is that, while you might not know the internal storage order of structure members, CF has to store (or output) them in some specific order, whether that's alphabetically or first-in, first-out or some other order. However, the "contract" provided by a structure doesn't guarantee what that order will be, so you shouldn't rely on it being some specific order - a structure is essentially an "unordered" container. I'm pretty sure that it's known behavior that in CF 4.5.x and higher, when you iterate over a structure, you'll get the keys in alphabetical order. However, if I recall correctly, in CF 4.0.x you'd get them in the order in which they were put in. In either case, one shouldn't rely on the keys being stored internally in some specific known order. There are containers analogous to structures in other languages, and the behavior is similar - you usually can't make assumptions about what order the keys will be in, when you loop over the container. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

