I think I like this one better than the Unix sort. It is really quick too. However I'd suggest using the SORT.LIST instead of the GET.LIST/MERGE.LIST:
SUBROUTINE HUB.SORT.C (ITAB) SORT.KEY = "tmpsortfile" SORT.KEY<2> = @UID SORT.KEY<3> = @USERNO SORT.KEY<4> = TIME() SWAP @AM WITH "_" IN SORT.KEY WRITELIST ITAB ON SORT.KEY CMD = "SORT.LIST ":SORT.KEY EXECUTE CMD CAPTURING MSG RETURNING ERR READLIST ITAB FROM SORT.KEY ELSE ITAB = "" 9999 RETURN END David Laansma IT Manager Hubbard Supply Co. Direct: 810-342-7143 Office:810-234-8681 Fax: 810-234-6142 www.hubbardsupply.com "Delivering Products, Services, and Innovative Solutions" -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rex Gozar Sent: Thursday, July 24, 2008 8:15 AM To: [email protected] Subject: Re: [U2] Basic SORT() Function not avail in UniVerse? And since no one has mentioned it yet, MERGE.LIST takes advantage of Universe's built-in (a.k.a "C") sorting ability. SUBROUTINE SORT.ITEM(ITEM) WRITELIST ITEM ON "MYLIST" STMT = "" STMT<-1> = "GET.LIST MYLIST" STMT<-1> = "MERGE.LIST 0 UNION 0" STMT<-1> = "SAVE.LIST MYLIST" READLIST ITEM FROM "MYLIST" ELSE ABORTM "IMPOSSIBLE!" DELETELIST "MYLIST" RETURN END Of course, this still adds the i/o overhead of reading and writing, but is still faster than LOCATE's on 1000+ element items. "[Another] aspect is that a lot dynamic arrays in programs do more than just hold keys..." which is why I wrote ROW2COL and QUICKSORT as complimentary subroutines (both on PickWiki). ROW2COL will flip associated multivalues "sideways" so QUICKSORT can sort and subsort on values in the corresponding "rows"; then I use ROW2COL to flip them back. Ideally, Universe should provide similar built-in functionality. rex ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
