David, thanks for the little challenge.
I took your code you suggested to try and created the below program: Please feel free to comment or improve the code. Unfortunately I don't have all day to refine (wish I could though). Due to company policy, I can't at this point in time release any code produced at this company other than the test code below. You'll see in the results that Records c-Sort uv-Sort 1,000 <0:01 0:06 10,000 <0:01 0:22 20,000 <0:01 1:19 50,000 0:01 8:34 999,999 20 (gave up after 25 minutes) Plus you really start to see the speed improvement when you also have to sort fields that have dependant attributes. Ps. We run IBM P series with lots of memory and cpu.... Final comment from Phil a colleague here: "What this points to is the need for IBM to develop an inbuilt high speed multivalue sort function call that uses faster methods then 'LOCATE' and 'INSERT'. Can we put this on the wishlist ????" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROGRAM TST.SORT * $INCLUDE SYINCLUDE COMMON * PROMPT " " scrPos = 3 CRT @(-1):@(3,scrPos):"*** START ***" scrPos += 2 CRT @(3,scrPos):"Number of ids ": INPUT NUM IF NOT(NUM) OR NUM < 1 THEN STOP END * scrPos += 2 CRT @(3,scrPos):"Start Time for RND function : ":TIMEDATE() EVALNUM = NUM * 100 VARIDS = '' FOR X = 1 TO NUM VARIDS := @VM:RND(EVALNUM) NEXT X VARIDS = DELETE(VARIDS,1,1,0) ;* first MV entry is null * scrPos += 2 CRT @(3,scrPos):"Time taken so far after RND build : ":OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),"MTS") * GOSUB RESORT.C * scrPos += 2 CRT @(3,scrPos):"Time taken so far after C version sort : ":OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),"MTS") * SortBy = 'DR' InArray = VARIDS AllowDups = @TRUE OutArray = '' GOSUB RESORT.U2: * scrPos += 2 CRT @(3,scrPos):"Time taken so far after U2 version sort : ":OCONV(((DATE()[EMAIL PROTECTED])*8400)+(TIME()[EMAIL PROTECTED]),"MTS") CRT CRT "*** END ***" * RETURN * * RESORT.C: * RECORD = VARIDS scrPos += 2 CRT @(3,scrPos):"Start sort function (C) version -- # of VM's ":COUNT(RECORD<1>,@VM) PARAM = "DR,1" CALL REORDER * RETURN * * RESORT.U2: * scrPos += 2 CRT @(3,scrPos):"Start sort U2 version -- # of VM's ":COUNT(InArray,@VM) If SortBy = "" then SortBy = "AL" * OutArray = Remove(InArray, MoreItems) * ArrayDelim = @RM:@AM:@VM:@SM:@TM[MoreItems, 1] * LOOP Item = Remove(InArray, MoreItems) Locate Item in OutArray by SortBy setting Pos then If AllowDups then Ins Item before OutArray<Pos> End else Ins Item before OutArray<Pos> End While MoreItems Do Repeat * * SWAP @AM, ArrayDelim in OutArray * RETURN * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test results: 1. *** START *** Number of ids 999999 Start Time for RND function : 09:57:08 24 JUL 2008 Time taken so far after RND build : 00:00:10 Start sort function (C) version -- # of VM's 999998 Time taken so far after C version sort : 00:00:30 Start sort U2 version -- # of VM's 999998 Break: Option (A,C,L,Q,?) =A DEV >TIME 10:22:11 24 JUL 2008 DEV > 2. *** START *** Number of ids 1000 Start Time for RND function : 10:29:36 24 JUL 2008 Time taken so far after RND build : 00:00:05 Start sort function (C) version -- # of VM's 999 Time taken so far after C version sort : 00:00:05 Start sort U2 version -- # of VM's 999 Time taken so far after U2 version sort : 00:00:06 *** END *** 3. *** START *** Number of ids 10000 Start Time for RND function : 10:30:07 24 JUL 2008 Time taken so far after RND build : 00:00:04 Start sort function (C) version -- # of VM's 9999 Time taken so far after C version sort : 00:00:04 Start sort U2 version -- # of VM's 9999 Time taken so far after U2 version sort : 00:00:22 *** END *** 4. *** START *** Number of ids 20000 Start Time for RND function : 10:53:51 24 JUL 2008 Time taken so far after RND build : 00:00:07 Start sort function (C) version -- # of VM's 19999 Time taken so far after C version sort : 00:00:07 Start sort U2 version -- # of VM's 19999 Time taken so far after U2 version sort : 00:01:26 *** END *** 5. *** START *** Number of ids 50000 Start Time for RND function : 10:56:26 24 JUL 2008 Time taken so far after RND build : 00:00:03 Start sort function (C) version -- # of VM's 49999 Time taken so far after C version sort : 00:00:04 Start sort U2 version -- # of VM's 49999 Time taken so far after U2 version sort : 00:08:38 *** END *** The information contained in this email and any attached files are strictly private and confidential. This email should be read by the intended addressee only. If the recipient of this message is not the intended addressee, please call Corporate Express Australia Limited on +61 2 9335 0555 or Corporate Express New Zealand Limited on +64 9 279 2555 and promptly delete this email and any attachments. The intended recipient of this email may only use, reproduce, disclose or distribute the information contained in this email and any attached files with Corporate Express' permission. If you are not the intended addressee, you are strictly prohibited from using, reproducing, disclosing or distributing the information contained in this email and any attached files. Corporate Express advises that this email and any attached files should be scanned to detect viruses. Corporate Express accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attached files. ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/