Hi Jamie,
This may not be applicable to your current problem, although since CF MX I
have almost done away with Structures in most circumstances and used Queries
to store complex information. The Query Of Query functionality allows you to
query subsets of Information from an existing query in memory. i.e you can
sort any column with ease.
For example. The first query directly accesses the database... and the last
query is based on qQueryA in memory, re-sorting it by ColumnB.
<cfquery name="qQueryA" datasource="#application.Datasource#" dbtype="ODBC">
select columnA, columnB from tableA order by ColumnA
</cfquery>
<cfquery name="qQueryB" dbtype="Query">
select * from qQueryA order by ColumnB
</cfquery>
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jamie
Lawrence Jenner
Sent: Monday, 10 May 2004 8:40 AM
To: CFAussie Mailing List
Subject: [cfaussie] Sorting a structure
wheres everybody gone, you aussies dont like working the weekends do ya!!
i have the code below, how can i sort the structure so that the structur
elements chart.data are sorted by their values.
cheers
Jamie
<cfscript>
reports = createObject("component","reports");
</cfscript>
<cfset chart = StructNew()>
<cfparam name="#url.graphStyle#" default="bar">
<cfinvoke component="#reports#" method="getnumsold"
returnvariable="getnumsold">
<cfinvokeargument name="vendorcode" value="#cookie.vid#">
<cfif Isdefined("url.product_id") and url.product_id neq "">
<cfinvokeargument name="product_id"
value="#url.product_id#">
</cfif>
</cfinvoke>
<cfif getnumsold.recordcount gt 0>
<cfloop query="getnumsold">
<cfset itemname=
"#getnumsold.name#"&"#getnumsold.product_id#">
<cfset chart.data[itemname] = #getnumsold.number_sold#>
</cfloop>
<cfset chart.scalefrom = 0>
<cfset chart.scaleto = 100>
<cfset chart.type = "#url.graphStyle#">
<cfelse>
No items match your search criteria. Please search again
</cfif>
<cfchart format="flash" scalefrom="0" scaleto="100" showborder="yes"
backgroundcolor="##FFFFFF" showlegend="yes" chartwidth="550"
chartheight="400" pieslicestyle="solid">
<cfchartseries type="#chart.type#" serieslabel="Products Sold"
seriescolor="##003366">
<cfloop collection="#chart.data#" item="i">
<cfchartdata item="#i#" value="#chart.data[i]#">
</cfloop>
</cfchartseries>
</cfchart>
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004
This message may contain privileged or confidential information and is
intended only for the individual named. If you are not the named addressee
you should not disclose, disseminate, distribute or copy this e-mail. If you
have received this e-mail by mistake please notify the sender immediately by
e-mail and delete this e-mail from your system. You should rely on your own
virus checking programmes and procedures for checking any attachments.
Please advise us if you wish your name and e-mail address to be removed from
our database.
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004