ArraySort() Issues
I am trying to sort some data from a query.
Here is the code:
<CFQUERY name="tope">
SELECT recipient,reccity,recstate
FROM orders
ORDER BY recipient
</CFQUERY>
<CFSET topearray = ArrayNew(2)>
<CFOUTPUT query="tope" group="recipient">
<CFSET ordercount = 0>
<CFOUTPUT>
<CFSET ordercount = ordercount + 1>
</CFOUTPUT>
<CFSET topearray[tope.currentrow][1] = "#ordercount#">
<CFSET topearray[tope.currentrow][2] = "#recipient#">
<CFSET topearray[tope.currentrow][3] = "#reccity#">
<CFSET topearray[tope.currentrow][4] = "#recstate#">
</CFOUTPUT>
<CFSET temp = ArraySort(topearray,"numeric")>
<CFOUTPUT>
<CFDUMP var="#topearray#">
</CFOUTPUT>
The Data from query have several orders from several recipients. Some receipients have ordered twice or more. So I grouped those recipients together in a loop and set some simple variables to calculate how many orders have been placed for each recipient.
This part works great!
I now need to sort this data to determine which recipients have ordered the most. I thought an array would be teh best solution, but can not get the ArraySort() to work for me.
I am specifically looking for the top 10 recipients that have placed the most orders.
When I dump my array prior to adding the ArraySort() command, it would bring back the correct data but I would find several "missing array elements" in the dump. What are these and how can I get rid of them?
Secondly, I need to sort the array by the first column of the array so that when I output the loop from the array I can specificy records 1 thru 10 to get my top 10 most active people ordering. It gives me errors everytime. The most specific error had to do with using a struct variable with an array. I wasn't even using Struct() commands. It would also tell me the data its trying to sort is not numeric. I know this, because it is trying to sort a non-numeric column - I do not know how to specifiy which column it sorts by.
Any help?
