Hey Joseph--

I used the following method to sort a 2-d array by column.  Check out the
code below, this file doesn't utilize fusebox but it could be fuseboxed
easily enough, that is the beauty of fusebox.


<!--- Press.cfm --->

<cfquery name="queryName" datasource="dsnName" >
Select whatever
>From whatever
Yadda Yadda Yadda
</cfquery>

<cfinclude template="header.cfm">
<div align="center">
<table width="500" border="0">
 <tr>
  <td align="center" colspan="3"><b><font face="Arial" size="4">In the
news...</font></b></td>
 </tr>
<cfif queryName.recordcount eq 0>
 <tr>
  <td align="center" colspan="3"><font face="Arial" size="4">No articles at
this time.</font></td>
 </tr>
<cfelse>
<cfset newsArray = ArrayNew(2)>
<cfloop query="queryName">
 <cfoutput>
  <cfset ii = "#queryName.currentrow#">
  <cfset newsArray[ii][1] = #queryName.itemID#>
  <cfset newsArray[ii][2] = #queryName.pubName#>
  <cfset newsArray[ii][3] = #queryName.pubDate#>
  <cfset newsArray[ii][4] = #queryName.pubHeadline#>
  <cfset newsArray[ii][5] = #queryName.pubLink#>
 </cfoutput>
</cfloop>

<cfparam  name="url.col" default="2">
<cfif #url.col# gt 4>
 <cfset col=3>
<cfelse>
 <cfset col=#url.col#>
</cfif>

 <tr>
  <td align="center" colspan="3"><font face="Arial" size="3">Click on a
heading to sort list by that category</font></td>
 </tr>
 <tr>
  <th align="left" width="150"><font face="Arial" size="2"><a
href="press.cfm?col=3">Date</a></font></th>
  <th align="left" width="200"><font face="Arial" size="2"><a
href="press.cfm?col=4">Headline</a></font></th>
  <th align="left" width="150"><font face="Arial" size="2"><a
href="press.cfm?col=2">Publication's Name</a></font></th>
 </tr>
 <!--- Now Do the Sorting. --->

 <cfset TotalRecords = #queryName.recordcount#>


  <cfset outerloopend = TotalRecords>
  <cfset innerloopend = TotalRecords-1>
  <cfset innerloopstart = 1>
  <cfset temp = 1>

   <cfloop index="outerloop" from="1" to="#outerloopend#">
     <cfloop index= "innerloop" from="#innerloopstart#" to="#innerloopend#">
       <cfif #newsArray[innerloop][col]# gt #newsArray[outerloop][col]#>
         <cfset temp = arrayswap(newsarray,outerloop,innerloop)>
        </cfif>
     </cfloop>
   </cfloop>

 <cfoutput>
 <cfloop query="queryName">
 <cfset ii = "#queryName.currentrow#">
 <tr>
  <td align="left"><font face="Arial" size="2">#DateFormat(newsArray[ii][3],
"M.D.YYYY")#</font></td>
  <td align="left"><font face="Arial" size="2"><a
href="pressFiles.cfm?type=2&newsFile=#newsArray[ii][1]#">#newsArray[ii][4]#<
/a></font></td>
  <td align="left"><font face="Arial" size="2"><a
href="http://www.#newsArray[ii][5]#"
target="_blank">#newsArray[ii][2]#</a></font></td>
 </tr>
 <cfif #queryName.recordcount# gt 1>
 <tr>
  <td colspan="3"><hr align="LEFT" size="1" width="500"
color="##ff9a00"></td>
 </tr>
 </cfif>
 </cfloop>
 </cfoutput>
</cfif>
</table>
</div>
<cfinclude template="footer.cfm">

------------------------------------------------------------------------------
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to