Sidebar: If we're concerned for speed, then don't have the DCOUNT in the end value of a FOR...NEXT loop. Set the variable once before the loop.
example: LAST=DCOUNT(ITAB,@AM) FOR X=1 TO LAST Mark Johnson ----- Original Message ----- From: "Dave Laansma" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, July 23, 2008 10:35 AM Subject: RE: [U2] Basic SORT() Function not avail in UniVerse? > I'd suggest this subroutine. Brief and to the point: > > SUBROUTINE HUB.SORT.B (ITAB) > > OTAB = "" > > FOR X = 1 TO DCOUNT(ITAB,@AM) > ELEM = ITAB<X> > LOCATE ELEM IN OTAB BY "AL" SETTING PLACE ELSE NULL > OTAB = INSERT(OTAB,PLACE;ELEM) > NEXT X > > ITAB = OTAB > > 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 Jeff Marcos > Sent: Tuesday, July 22, 2008 7:35 PM > To: [email protected] > Subject: RE: [U2] Basic SORT() Function not avail in UniVerse? > > We had the same issue back in the 90's. So a clever guy (Ed) that worked > with us wrote a small C program (on Unix) to do the sort. This also > included controlling/dependants fields. Any universe program could call > it, passing in the variables and returned the items sorted. > > Speed is incredible. To this day it's still used and blitzes any > universe program methods in sorting large arrays. > > Regards, > Jeff Marcos > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood > Sent: Wednesday, 23 July 2008 6:59 AM > To: [email protected] > Subject: RE: [U2] Basic SORT() Function not avail in UniVerse? > > Hey, and don't forget to do a speed test. You know, because LOCATE is > coded > as part of the OS it just *might* be faster than bubble or speed sort > options. > > In fact, this was a topic on this list about 3 or 4 years ago and > someone > doing the speed test concluded LOCATE was in fact faster. > > And no I don't remember who it was, or have a link to the thread (sorry) > > :-) > > Allen > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Israel, John R. > Sent: Tuesday, July 22, 2008 10:26 > To: '[email protected]' > Subject: RE: [U2] Basic SORT() Function not avail in UniVerse? > > > Note that if the array is big, you would get much better performance by > loading it into a DIM array, so the sort of sort below, then put the > results > back into a dynamic array. > > Dynamic arrays are much easier to use, but when used wisely, dimensioned > arrays can be MUCH faster. This is true for any application, esp. > looping > through multi-values. > > John Israel > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN > Sent: Tuesday, July 22, 2008 1:00 PM > To: [email protected] > Subject: RE: [U2] Basic SORT() Function not avail in UniVerse? > > This is a UniData subroutine, but should work .... > > SUBROUTINE B42.SORT.ARRAY(SORTED,ARRAY) > * Bubble sort the elements of a dynamic array > * Created by: David Wademan > * Creation Date: 01/05/05 > SORTED="" > VALUES = DCOUNT(ARRAY,@VM) > LOOP > CHANGES = 0 > FOR X = 2 TO VALUES > * For each adjacent pair > ELEMENT1 = ARRAY<1,X-1> > ELEMENT2 = ARRAY<1,X> > > IF ELEMENT2 < ELEMENT1 THEN > * Swap if pair out of sequence > ARRAY<1,X> = ELEMENT1 > ARRAY<1,X-1> = ELEMENT2 > CHANGES = 1 > END > NEXT X > WHILE CHANGES DO REPEAT > SORTED=ARRAY > RETURN > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes > Sent: Tuesday, July 22, 2008 10:51 AM > To: '[email protected]' > Subject: [U2] Basic SORT() Function not avail in UniVerse? > > Hey, > > I'm needing to SORT a dynamic array and apparently UniVerse doesn't have > this > Function. > > Other MV implementations have this, such as D3 - "The sort() function > sorts an > attribute or value mark delimited str.exp in ascending order." [from > ePick] > > There was also a user exit u1072 that did the same thing. > > Does anyone have a work around or fast path to same thing .... maybe I'm > missing something but can't see this in UV docs. > > -Baker > ------- > 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/ > ------- > 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/ > > 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 > [email protected] > To unsubscribe please visit http://listserver.u2ug.org/ > ------- > 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/
