Hi Chuck, You don't need to do any reordering!
I use this technique when sorting multiple variables at the same time off of the same index. I haven't tested this, and am working on my first cup of coffee so excuse me if I get the syntax wrong, or put in a stoooopid error. All this does is keep SORT.INDEX and SORT.DATA in the same order, so you do your lookup on SORT.INDEX with just the 5th element (a great movie, btw) and then propagate SORT.INDEX with the 5th element and SORT.DATA with all the elements, but using the location found during the lookup of the 5th element (did I mention I like that movie?) ;-) SORTED.DATA = "" SORT.INDEX = "" SORT.COUNT = DCOUNT(REC,@AM) FOR J = 1 TO SORT.COUNT LOOK.FOR = REC<J,5> LOCATE LOOK.FOR IN SORT.INDEX<1> SETTING FOUND THEN SORT.INDEX = INSERT(SORT.INDEX,FOUND,1,1,LOOK.FOR) SORT.DATA = INSERT(SORT.DATA,FOUND,1,1,REC<J>) NEXT J REC = SORT.DATA I have NO idea how the speed of this will compare with the other techniques described, but I have used this with HUGE updates on very large files (making history files out of transaction files for sales analysis and forecasting) and the speed was acceptable....... Hope this helps! *=aee=* Allen E. Elwood Senior Programmer Analyst Curnayn and Associates Direct (818) 361-5251 Fax (818) 361-5251 Cell (818) 359-8162 Home (818) 361-7217 -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Chuck Mongiovi Sent: Tuesday, July 27, 2004 05:28 To: [EMAIL PROTECTED] Subject: RE: [U2] merge sort > Just to avoid the obvious question, you have tried using the LOCATE and > INSERT commands? If not this is an easy to use construct. No, I have to admit that I haven't .. In order to use LOCATE, I have to transpose my data: >REC<1> = A]W]1]5]15 >REC<2> = B]X]2]6]25 >REC<3> = C]Y]3]7]100 >REC<4> = D]Z]4]8]11 to REC<1> = A]B]C]D REC<2> = W]X]Y]Z REC<3> = 1]2]3]4 REC<4> = 5]6]7]8 REC<5> = 15]25]100]11 I think this (and some version of the SHELL sort or DIMmed arrays) will work for me .. Thanks for all of the help everyone .. -Chuck ------- ------- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/