Um - have you looked at structSort() ?

On 8/11/05, Brett Barnhart <[EMAIL PROTECTED]> wrote:
> I've been playing with this for awhile and I can't quite seem to get it to 
> work. (Nothing new there!)
> 
> I have a search page and I want to rate results with relevance to the search.
> 
> So, I decided to loop through all the possible listings and place them into a 
> struct
> 
> Structs still confuse me a bit, so I am using code from something someone 
> else wrote and morphing it to my needs.
> 
> Here is my code...
> 
> <cfparam name="session.sales" default="">
>         <cfset searchdata = session.sales>
> 
> <cfif IsArray(searchdata) Is 0>
>         <cfset searchdata = ArrayNew(1)>
> </cfif>
> 
> <cfloop>
> 
> <snip....>
> 
> <cfset variables.searchLen = arrayLen(searchdata) + 1>
> <cfset searchdata[variables.searchLen] = StructNew()>
> <cfset searchdata[variables.searchLen].listing_id = sale_id>
> <cfset searchdata[variables.searchLen].score = score>
> </cfloop>
> 
> listing_id primary key
> score is the relevance.
> 
> Now, I'd like to loop through the structure in desc order of score.
> 
> <cfloop index="count" from="1" to="#variables.searchLen#">
> <cfoutput>#searchdata[count].listing_id# : 
> #searchdata[count].score#<br/></cfoutput>
> </cfloop>
> 
> Which currently gives
> 
> Sale # 33 has a score of 67%
> Sale # 31 has a score of 33%
> Sale # 27 has a score of 0%
> Sale # 28 has a score of 33%
> Sale # 29 has a score of 33%
> Sale # 30 has a score of 33%
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:214717
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to