I'm not sure I understand the problem then.  Ordering the query will cause myArray to be built already sorted.  When you step through from 1 to total_records, the display will be correct.

What am I missing?

At 6/7/2001 09:05 AM, you wrote:
Sure I could do that but I need to sort the array for this particular problem - any other suggestions?
-----Original Message-----
From: Jeff Mayfield [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 9:04 AM
To: [EMAIL PROTECTED]
Subject: Re: Help with Arrays

I would add order by lname to the query.

Jeff

At 6/7/2001 07:40 AM, you wrote:

I need help sorting the array alphabetically by last name.  Here is the code:

<CFQUERY NAME="test" DATASOURCE="sales">
    SELECT id, fname, lname
    FROM reps
</CFQUERY>

<CFSET myarray=ArrayNew(2)>

<CFLOOP QUERY="TEST">
        <CFSET myarray[CurrentRow][1]=test.id[CurrentRow]>
        <CFSET myarray[CurrentRow][2]=test. fname[CurrentRow]>
        <CFSET myarray[CurrentRow][3]=test.lname[CurrentRow]>
</CFLOOP>

<CFSET Total_Records=Test.RecordCount>

<CFLOOP INDEX="Counter" FROM=1 TO="#Total_Records#">
    <CFOUTPUT>
        ID: #MyArray[Counter][1]#,
        FIRST NAME: #MyArray[Counter][2]#,
        Last NAME: #MyArray[Counter][3]#
       <BR>
    </CFOUTPUT>
</CFLOOP>

- Dave

Reply via email to