I misread your original post, so this should do it (adapted from previous version):


<!--- Supposing txt is your file, acctno is digits only and dates are in mm-dd-yyyy format --->
<cfset qLines = QueryNew("line,acctno,date")>
<cfloop list="#txt#" delimiters="#chr(10)##chr(13)#" item="line">
<cfscript>
stTmp = REFind("^(\d+),(\d+)-(\d+)-(\d+),",line,1,true);
acctno = Mid(line,stTmp.pos[2],stTmp.pos[2]);
date =  Mid(line,stTmp.pos[5],stTmp.pos[5]) & "-" & Mid(line,stTmp.pos[3],stTmp.pos[3]) & "-" & Mid(line,stTmp.pos[4],stTmp.pos[4]);
QueryAddRow(qLines);
QuerySetCell(qLines,"line",line);
QuerySetCell(qLines,"acctno",acctno);
QuerySetCell(qLines,"date",date);
</cfscript>
</cfloop>
<cfquery dbtype="query" name="qLinesSorted">
SELECT line
FROM qLines
ORDER BY acctno, date DESC
</cfquery>
<cfset newtxt = "">
<cfoutput query="qLinesSorted">
  <cfset newtxt = newtxt & qLinesSorted.line & chr(10)>
</cfoutput>

> -----Original Message-----
> From: Pascal Peters
> Sent: woensdag 30 juni 2004 16:16
> To: CF-Talk
> Subject: RE: Sorting help!
>
> The problem is that the dates are sorted alphabetically. I
> would create a query with acct n�, date in ISO format and
> file and use query of query. I will post some code in 10' or so
>
> Pascal
>
> > -----Original Message-----
> > From: Jeff Waris [mailto:[EMAIL PROTECTED]
> > Sent: woensdag 30 juni 2004 15:46
> > To: CF-Talk
> > Subject: Sorting help!
> >
> > Got a real odd sorting problem here, and I am kind of stumped....
> >  
> > Using CFHTTP, I generate a file on the fly that contains some user
> > information. It has three fields on each line, constituting
> 1 record.
> > This file cannot be formatted any other way. I have no control over
> > it. (Until it gets to me)
> >  
> > the file is formatted like this
> >  
> > 11111111,01-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,02-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,03-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,04-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 22222222,01-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 22222222,02-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 22222222,03-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 22222222,04-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> >  
> > Field one is an account number, field two is a date and the third
> > field is an associated picture(uniquely named for each
> > line) The dates may range over a year or two. the file is sorted by
> > account number then by date ascending.
> > I need to sort by account number then by date DESCENDING.
> >  
> > I've tried to sort descending, by treating each line as a list item
> > using listsort(). It almost works. For everything under a year, the
> > list sort is fine, but anything with entries over 1 year for an
> > account I would get this:
> >
> >  
> > 11111111,01-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,01-01-2004,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,02-01-2003,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,02-01-2004,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,03-01-2004,xxxxxxxxxxxxxxxxxxx.jpg
> > 11111111,04-01-2004,xxxxxxxxxxxxxxxxxxx.jpg
> >  
> > I was thinking of putting everything in array, but I don't think I
> > will be able to sort them the way I want this way either.
> Is there a
> > way to do this without database intervention? Any help would be
> > greatly appreciated...
> >  
> > Thanks!
> > Jeff
> >
> >
> >
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to