Where did you find reference to StructKeySort? There's a StructSort, is that
what you meant?

Adrian

-----Original Message-----
From: Wil Genovese [mailto:[EMAIL PROTECTED]
Sent: 25 June 2007 19:45
To: CF-Talk
Subject: Cfloop sort bug or am I crazy?


I am using cfloop to loop over a structure and outputting it's key
values pairs as a simple form check box list.

The problem is that the output is no longer sorted in the proper order
when I loop over the structure.  The cfmx7 migration PDF from Adobe says
that the behavior for CFloop changed in CFMX7 and it loops in the order
the structure was created instead of auto sorting.

 From the PDF.
"cfloop
Change
ColdFusion MX ColdFusion MX returns struct keys in the order that you
create them. ColdFusion 5 returns struct keys in alphabetical order.
To sort struct values or keys, use the StructSort and StructKeySort
functions."

I have noticed that cfmx 7.02 Enterprise does not follow this rule.
Also, the StructKeySort function seems to be MIA.  I have created a work
around, but I thought I'd mention this here since the behavior does not
seem to match the the documentation.  Either it never did, or it was
changed and the docs never changed.  Or hey, there could be newer docs
that specify the change that I haven't seen.  I'm curious and would like
to know what is really supposed to happen.

The structure is very simple and gets populated from an alpha ordered
query.  Even when I create the structure manually I get the same messed
up output.  The odd thing is CFDUMP outputs the structure sorted by key
name.

The Code:
<cfset serverlist = structnew()>
<cfset serverlist["Integrated1"] = "I1">
<cfset serverlist["Mlsfinder1"] = "m1">
<cfset serverlist["Mlsfinder2"] = "m2">
<cfset serverlist["Mlsfinder3"] = "m3">
<cfset serverlist["Mlsfinder4"] = "m4">
<cfset serverlist["Mlsfinder5"] = "m5">
<cfset serverlist["Mlsfinder6"] = "m6">

<cfloop collection="#serverlist#" item="theservername">
    <cfoutput>#theservername#</cfoutput><br />
</cfloop>

<cfdump var="#serverlist#">

<!--- this line errors out --->
<cfset sorted = StructKeySort(serverlist,'TextNoCase','Asc')>

Server info:
Server Product  ColdFusion MX
Version         7,0,2,142559
Edition         Enterprise
Operating System        UNIX
OS Version      2.6.9-42.0.10.ELsmp



Thanks,

--
Wil Genovese


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:282109
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to