Brendan,
I see now. Very nice.

Greg

-----Original Message-----
From: Brendan Avery [mailto:[EMAIL PROTECTED]
Sent: Monday, March 15, 2004 4:27 AM
To: CF-Talk
Subject: RE: Compare List

That's what the ListSort function embedded in the Compare function was
for.  As long as both lists contain the exact same entities it doesn't
matter if they're in different orders if you embed those ListSort
functions.  Perhaps my code was unclear.  Here let me elaborate:

<cfset list1="1,2,3,4,5">
<cfset list2="3,1,2,5,4">
<cfset result=Compare(ListSort(list1,"text"),ListSort(list2,"text"))>
<cfif result IS 0>
THEY ARE THE SAME!!
<cfelse>
THEY ARE NOT THE SAME!!
</cfif>

;-P

Maybe that wasn't the point of your question though-- I think your
algorithm for doing the list compare is valid and beautiful in any case.
Its just not necessary to do it algorithmically when CF is so generous
with its List related functions.

Peace!

-b

-----Original Message-----
From: Greg Luce [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 14, 2004 6:43 PM
To: CF-Talk
Subject: RE: Compare List

Brendan,
What would you use to for the sort order? These lists can be in
any order. Such as: 1,2,3,4,5 And 3,1,2,5,4

How would you compare these 2 lists using these functions?

Greg

-----Original Message-----
From: Brendan Avery [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 14, 2004 5:29 PM
To: CF-Talk
Subject: RE: Compare List

Compare(ListSort(list1,"text"),ListSort(list2,"text")

Boo-yah.

== Brendan Avery -- http://www.brendanavery.com ==

-----Original Message-----
From: Greg Luce [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 14, 2004 1:40 PM
To: CF-Talk
Subject: RE: Compare List

You're looking for a match where both lists contain the same values, but
possibly in different orders right? I would try:

<cfset state_list = "1,2,3,4,5,6,7,8">
<cfset query_list = "9,8,7,6,5,4,3,2">

<cfif listlen(state_list) EQ listlen(query_list)>
  <cfloop index="i" list="#state_list#">
    <cfif NOT listcontains(query_list, i)>
      Not A Complete Match<cfabort>
    </cfif>
  </cfloop>
  Lists Match
<cfelse>
  Not Same Length Match
</cfif>

Greg

-----Original Message-----
From: cfhelp [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 14, 2004 2:13 PM
To: CF-Talk
Subject: Compare List

Will Compare(String1,String2) work to compare a list?

I have a Comma Delimited list of GUIDS (up to 50 for each state). That I
need to compare to a list GUIDS from a Query. If they match then return
true (1).

The GUIDS in the list may not be in the same order as the GUIDS from the
query.

Any ideas?

Rick

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.583 / Virus Database: 369 - Release Date: 2/10/2004
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to