Philip wrote:
> Thanks,
> You confirmed what I realized too.
> i've resorted to a cursor then back to copy to array.
> 
> Thanks,
> Philip
> 
> Vince Teachout wrote:
>> Automation Plus wrote:
>>   
>>> hey all
>>> How do I sort a two dimensional array 1st on the 2nd column and within 
>>> the 2nd column the 1st column?
>>>     
>> I don't believe you can do it with the Asort command.  You'd probably 
>> have to use a cursor.
>>

You could, first you sort on the second column with
aSort(myArray, aElement(myArray, 1, 2))

Then you might go through myArray till the second column changes, lets
say myArray(10,2) = 20 and myArray(20, 2) = 20 and myArray(21, 2) = 21
so now you have to sort myArray from row 1 to row 10 by the 1st column :
aSort(myArray, aElement(myArray, 10, 1), 11)
               ^^^^^^^^^^^^^^^^^^^^^^^^ start ordering in row 10, order
by column 1
                                         ^^ order 11 rows


Here's an example :

dime myArray(100,2)

for x = 1 to 10
        for y = 1 to 10
                myArray((x-1)*10+y, 1) = 11 - y
                myArray((x-1)*10+y, 2) = 11 - x
        endfor
endfor

aSort(myArray, aElement(myArray, 1, 2)) && sorted by 2nd column

nPrevVal = myArray(1, 2)
nPrevRow = 1
for nRow = 1 to 100
        if nPrevVal != myArray(nRow, 2)
                aSort(myArray, ;        && sort sub-Array by 1st column
                        aElement(myArray, nPrevRow, 1), ;
                        nRow - nPrevRow)
                nPrevVal = myArray(nRow, 2)
                nPrevRow = nRow
        endif
endfor



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to