Sure, use an array. Seriously though - struct keys are not meant to be ordered. If you want it ordered, just use an array of structs.
======================================================================== === Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc (www.mindseye.com) Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia) Email : [EMAIL PROTECTED] Blog : www.camdenfamily.com/morpheus/blog Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda > -----Original Message----- > From: Suyer, Ed [PRD Non-J&J] [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 31, 2003 8:55 AM > To: CF-Talk > Subject: Preserve collection order > > > Hi folks, > > Does anyone know of a way to preserve the order of keys in a > structure so that it matches the order in which it was created? > > i.e. > > I created a structure that looks like so: > > instance structNew(); > > instance["id"] = structNew(); > instance["id"].heading = "Id"; > instance["id"].size = 50; > > instance["manufacturer_name"] = structNew(); > instance["manufacturer_name"].heading = "MFG"; > instance["manufacturer_name"].size = 200; > > instance["name"] = structNew(); > instance["name"].heading = "Name"; > instance["name"].size = 100; > > instance["parttype_name"] = structNew(); > instance["parttype_name"].heading = "Part Type"; > instance["parttype_name"].size = 100; > > instance["status_name"] = structNew(); > instance["status_name"].heading = "Status"; > instance["status_name"].size = 100; > > When I cfloop through it ( i.e. for ( field in instance ) {} > ), I would expect it to find the "id" field first, then > "manufacturer_name", and so on and so fourth in the order in > which the structure was created. Instead it loops through in > this order: name,id,parttype_name,manufacturer_name,status_name > > I figured I'd try to trick it by doing a structKeyList() then > cflooping through that, but it returns the same thing: > name,id,parttype_name,manufacturer_name,status_name > > Does anyone know of a way to cfloop through this structure in > the order in which it was created: > id,manufacturer_name,name,parttype_name,status_name ? > > TIA! > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

