I've been experimenting and discovered something.  Instead of waiting
until you have all (say) 100,000 elements to sort at once, why not sort
them in blocks of (say) 5,000.  So I wrote this little subroutine that
takes two parameters, a relatively small un-sorted table and the larger
sorted table and sorts the un-sorted into the sorted table.

The calling program accumulates the unsorted ITAB and when it reaches a
certain watermark, say 5,000 elements, this subroutine is called and
those 5,000 get inserted into the master sorted OTAB, which initially is
<null>.

My experimentation discovered this method to run extremely quickly
compared to waiting for the entire 100,000 element table to be built
before starting the sort.  Try it out!

  SUBROUTINE HUB.SORT.B (ITAB,OTAB)

  X2    = DCOUNT(ITAB,@AM)

  FOR X = 1 TO X2
    ELEM = ITAB<X>
    LOCATE ELEM IN OTAB BY "AL" SETTING PLACE ELSE NULL
    OTAB = INSERT(OTAB,PLACE;ELEM)
  NEXT X

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: u2-users@listserver.u2ug.org
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: u2-users@listserver.u2ug.org
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: 'u2-users@listserver.u2ug.org'
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: u2-users@listserver.u2ug.org
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: 'u2-users@listserver.u2ug.org'
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
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
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
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to