Dan
-----Original Message-----
From: DURETTE, STEVEN J (AIT) [mailto:[EMAIL PROTECTED]
Sent: Monday, January 12, 2004 1:24 PM
To: CF-Talk
Subject: RE: Structures native order
This sounds to me like a good case for a combo array/structure.
Try this:
<!--- Create the array --->
<cfset Variables.myStateInfo = arrayNew(1)>
<!--- Create Struct and populate the array/struct --->
<cfloop from="1" to="#myQueryName.recordCount#" index="Variables.myIndex">
<cfset Variables.myStateInfo[Variables.myIndex] = structNew()>
<cfset Variables.myStateInfo[Variables.myIndex].stateNumber =
myQuery.stateNumber>
<cfset Variables.myStateInfo[Variables.myIndex].stateName =
myQuery.stateName>
</cfloop>
<!--- Then to output. --->
<cfoutput>
<cfloop from="1" to="#arrayLen(Variables.myStateInfo)#"
index="Variables.nextIndex">
State Number:
#Variables.myStateInfo[Variables.nextIndex].stateNumber#
State Name:
#Variables.myStateInfo[Variables.nextIndex].stateName#<br />
</cfloop>
</cfoutput>
Steve
-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]
Sent: Monday, January 12, 2004 1:17 PM
To: CF-Talk
Subject: RE: Structures native order
> If I loop over a query, which I have retrieved in the order I
> want it in, and add the data to a structure, I am finding it
> does not stay in that order. A few records from the query:
>
> 262 Alabama
> 211 Alaska
> 212 Arizona
> 213 Arkansas
> 214 California
>
> When I loop over the collection and display it, it seems to
> sort on the numeric id, instead of the order I inserted the
> records into the structure. Consequentially, Alabama ends up
> last. I do not recall running into this before.
In general, I would recommend that you not use structures to contain ordered
data. The behavior of structures with regard to ordering has changed several
times since they've been introduced to CF. If you want ordered data, use an
array.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/ <http://www.figleaf.com/>
voice: (202) 797-5496
fax: (202) 797-5444
_____
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

