Hi Roger,

Thanks so much!!! I did not believe that it would be so easy!!

Miriam Hirschman

-----Original Message-----
From: Roger Lim [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 21, 2000 12:01 AM
To: [EMAIL PROTECTED]
Subject: Re: alphabetical Order


There is no built-in function to handle this in CF. but you can have a CFML
custom tag that you can use to order your results.

After your <CFSEARCH>, call out the below custom tag and whola! you're done.
;)

<!--- Example of use

<CF_QuerySort
 Query="MyQuery"
 SORTCOLUMN = "MyColumn"
 SORTORDER = "Desc"    <- optional, defaults to Asc
 SORTTYPE = "Numeric"    <- optional, defaults to Textnocase
 SORTEDQUERY = "MySortedQuery" <- optional, defaults to "Sorted"

--->

<!--- Suspend Output --->
<cfsetting enablecfoutputonly="yes">

<!--- Required Parameters --->
<cfparam name="attributes.query">
<cfparam name="attributes.sortcolumn">

<!--- Optional Parameters --->
<cfparam name="attributes.sorttype" default="textnocase">
<cfparam name="attributes.sortorder" default="asc">
<cfparam name="attributes.sortedquery" default="sorted">

<!--- Establish local versions of queries --->
<cfset myarray = arraynew(1)>
<cfset myquery = evaluate("caller.#attributes.query#")>
<cfset newquery = querynew(myquery.columnlist)>

<cfif myquery.recordcount GT 999999>
 <cfabort showerror="Only Queries with less than one million rows can be
sorted. Your Query has #myquery.recordcount# rows.">
</cfif>

<!--- Add row number to end of each row's value --->
<cfoutput query="myquery">
 <cfset myarray[currentrow] = evaluate("myquery.#attributes.sortcolumn#") &
numberformat(currentrow, "000009")>
 <cfset temp = queryaddrow(newquery)>
</cfoutput>

<!--- Sort array --->
<cfset temp = arraysort(myarray, attributes.sorttype, attributes.sortorder)>

<!--- Populate new query, row by row, with appropriate row of old query --->
<cfloop from="1" to="#myquery.recordcount#" index="this">
 <cfset row = val(right(myarray[this], 6))>
 <cfloop list="#myquery.columnlist#" index="col">
  <cfset temp = querysetcell(newquery, col, evaluate("myquery.#col#[row]"),
this)>
 </cfloop>
</cfloop>

<!--- Pass sorted query back to calling template --->
<cfset "caller.#attributes.sortedquery#" = newquery>

<!--- restore output --->
<cfsetting enablecfoutputonly = "no">

roger lim

----- Original Message -----
From: "Miriam Hirschman" <[EMAIL PROTECTED]>
To: "CF Forum" <[EMAIL PROTECTED]>
Sent: Monday, August 21, 2000 10:44 AM
Subject: alphabetical Order


> I am searching through a bunch of word documents using cfsearch.  I  then
> loop through them and output the fields.  How do I get CF to put them in
> alphabetical order??
>
> Thanks,
>
> ---miriam
>
> --------------------------------------------------------------------------
----
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar

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

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

Reply via email to