*!* Shorter code, lower performance * Would count for a trick maybe :) * But any cursor, whatever the size is, would write to disk * so larger the array, slower the result I think * unless not already a cursor or table *!* dimension myarray[15,2] *!* =rand(-1) *!* for ix = 1 to 15 *!* myarray[ix,1] = int(rand()*5) *!* myarray[ix,2] = chr(int(rand()*5)+65) *!* endfor *!* clear *!* create cursor mycursor (c1 i, c2 c(1)) *!* append from array myarray *!* select * from mycursor into array myarray order by 1,2 *!* use in "mycursor" *!* for ix = 1 to 15 *!* ? myarray[ix,1], myarray[ix,2] *!* endfor *!* Larger code, faster performance - MAXELEMCOUNT dropped to MAXELEMCOUNT*2/3 clear #define ROWCOUNT 15 #define COLCOUNT 2 #define SORTEXPRESSION "str(myarray[ix,1])+ myarray[ix,2]" dimension myarray[ROWCOUNT,COLCOUNT] =rand(-1) ? "Before sort..." for ix = 1 to ROWCOUNT myarray[ix,1] = int(rand()*5) myarray[ix,COLCOUNT] = chr(int(rand()*5)+65) ? myarray[ix,1], myarray[ix,2] endfor ************** =InsDelColumn(@myarray,ROWCOUNT,COLCOUNT) && Add a temp sort column for ix = 1 to ROWCOUNT myarray[ix,(COLCOUNT + 1)] = eval(SORTEXPRESSION) endfor =asort(myarray,(COLCOUNT + 1)) && Do sort =InsDelColumn(@myarray,ROWCOUNT,COLCOUNT, .T.) && Remove temp sort column ************** ? "After sort..." for ix = 1 to ROWCOUNT ? myarray[ix,1], myarray[ix,2] endfor * function InsDelColumn * Insert or remove a column from array at the end column * Resize array to tnRows, tnCols if remove, tnRows, tnCols+1 if add function InsDelColumn lparameters taTempArray, tnRows, tnCols, tlRemove local ix * Conv. to one dim - just for ease of coding array subscript dimension taTempArray[tnRows * (tnCols + 1)] if tlRemove && Is it a column removal ? for ix = ROWCOUNT to 1 step -1 =adel(taTempArray,(ix-1) * (tnCols + 1) + (tnCols + 1)) endfor else && or column add ? for ix = 1 to tnRows =ains(taTempArray,(ix-1) * (tnCols + 1) + (tnCols + 1)) endfor endif && Back to two dim. with resize dimension taTempArray[tnRows,( tnCols + iif(tlRemove,0,1) )]Cetin