Teach it right man.  You can get by with a list here, but it's Fugly.

Lists are the bastard child of CF.  They are really just strings, and the
list functions just do a bunch of EXPENSIVE string manipulation on the back
end.  For uses like what he wants an array is the right way.  It's faster
and if necessary you can add dimensions to the array to allow for attributes
he can sort on or whatever.

Tim
  -----Original Message-----
  From: Mark Smyth [mailto:[EMAIL PROTECTED]
  Sent: Thursday, November 27, 2003 10:48 AM
  To: CF-Community
  Subject: RE: How can I sort a <cfloop results

  just do this - on reflection forget about arrays, listsort will do it fine

  <cfset sortedList = ListSort(i, "Text")>

  -----Original Message-----
  From: Bushy [mailto:[EMAIL PROTECTED]
  Sent: 27 November 2003 15:45
  To: CF-Community
  Subject: RE: How can I sort a <cfloop results

  Could you give an example?

  --Original Message Text---
  From: Mark Smyth
  Date: Thu, 27 Nov 2003 15:36:45 -0000

  right i'm with you know, you just want to output the list contents in an
  ordered manner.   You could do this programmatically, but really if you
need
  ordered data use an array instead of a list, arrays are built to manage
  ordered data.

  You can't do a query, what would you order on even if you could?

  hth
  mark

  -----Original Message-----
  From: Bushy [mailto:[EMAIL PROTECTED]
  Sent: 27 November 2003 15:18
  To: CF-Community
  Subject: RE: How can I sort a <cfloop results

  OK but from your example the QUERY is a table?

  So if I have this...

  <CFSET SESSION.items = LISTAPPEND(SESSION.items,URL.list)>

  SESSION.items =
  /temp/dir1,/temp/dir2,/temp/dir3,file1.txt,/temp/dir4,file2.txt

  I can do this?

  <CFQUERY NAME="test" DBTYPE="query">
  SELECT *
  FROM '#SESSION.items#'
  ORDER BY ??
  </CFQUERY>

  I'm current;y doing a <CFLOOP> but require a osret function.

  <CFLOOP INDEX="i" LIST="#SESSION.items#">
  #i#
  </CFLOOP>

  --Original Message Text---
  From: Mark Smyth
  Date: Thu, 27 Nov 2003 15:09:48 -0000

  you mean

  select * from tbl where field = ( '/temp/dir1' or '/temp/dir2'  or ....)
  order by ....

  if so just loop over the list and manipulate it so it will fit into the
  above??

  So the answer to your question:
  >>Can I do a <CFQUERY on the above SESSION variable and then do a sort
ORDER
  BY and >>output the results?
  is yes

  -----Original Message-----
  From: Bushy [mailto:[EMAIL PROTECTED]
  Sent: 27 November 2003 15:00
  To: CF-Community
  Subject: RE: How can I sort a <cfloop results

  Maybe I didn't explain it properly.

  Let's try this.

  I have a SESSION variable that contains a list of files and directories.
For
  example:

  <CFSET SESSION.items = LISTAPPEND(SESSION.items,URL.list)>

  SESSION.items =
  /temp/dir1,/temp/dir2,/temp/dir3,file1.txt,/temp/dir4,file2.txt

  Can I do a <CFQUERY on the above SESSION variable and then do a sort ORDER
  BY and output the results?

  --Original Message Text---
  From: Mark Smyth
  Date: Thu, 27 Nov 2003 14:09:44 -0000

  <cfoutput>#right("/temp/dir1", 4)#</cfoutput> in the loop will take
  "/temp/dir1" and output dir1

  you will have to handle #i# if it changes format (as in file2.txt), but
you
  can use find again to do this

  You can also do a query if you need to based on #i# within the loop
  hth
  Mark

  -----Original Message-----
  From: Bushy [mailto:[EMAIL PROTECTED]
  Sent: 27 November 2003 12:26
  To: CF-Community
  Subject: re: How can I sort a <cfloop results

  I have two frames. the top frame display directories/files which the user
  can click. When they click on a link the path and filename are sent and
  displayed in the bottom frame.
  Basically when a link is clicked the <A HREF reloads the bottom frame
  displaying the directories/files.

  Let's say the SESSION.item variable is equal to
  "/temp/dir1,/temp/dir2,/temp/dir3,file1.txt,/temp/dir4,file2.txt"

  Currently the above list displays "as-is". How can I sort the above with
  directories displaying first?

  Can I do a <CFQUERY on the "i" results and then do a ORDER BY somehow?

  <CFOUTPUT>
  <CFLOOP INDEX="i" LIST="#SESSION.item#>
  #i#
  </CFLOOP>
  </CFOUTPUT>

    _____

    _____

    _____

    _____


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to