Hi Jacques,

Here's one I wrote to replace a very ugly situation where the original
depended on each element having it's own name.  It uses 'indirect
addressing' to accomplish the sort, so basically all you have to do is to
add the attribute numbers that need to be sorted in the ATTR.LIST and then
set the attr that the sort is to be based off of in the SORT.ATTR and it
does the rest.

Hopefully this is the debugged version.  If it doesn't work, let me know and
I'll rip the piece out of the program that I put it in.  As you can see this
version was setup to read a record from an order backup file, sort the
attr's and then write it with a different ID so I'm pretty sure it's the one
that I used to get the routine running before slapping it back into the
invoice print.

Hope this helps!

Allen E. Elwood
www.tortillafc.com <http://www.tortillafc.com>
Tortilla Flats Consulting
(818) 361-5251 Direct
(818) 361-5251 Fax
(818) 359-8162 Cell
(818) 361-7217 Home


*SORT.ROUTINE Sort unlimited associated fields off of one field
OPEN '', 'ORDER.BACK' TO ORDER.BACK ELSE PRINT "I'm melting!"
READ ORD FROM ORDER.BACK, "LXXXX" ELSE PRINT 'huh, what?' ; STOP
* Setup Parameters
SORT.REC   = ORD
ATTR.LIST  = "12,13,31,32,40,49,66,87,88,89,90,91,92,93"
ATTR.LIST  = CHANGE(ATTR.LIST, ",", @AM)
ATTR.COUNT = DCOUNT(ATTR.LIST,@AM)
DATA.BASE  = ""
SORT.ATTR  = 11
SORT.BASE  = ""
SORT.COUNT = DCOUNT(SORT.REC<SORT.ATTR>,@VM)
* Sort the data based off of the sort attribute in the sort record
FOR SORT.I = 1 TO SORT.COUNT
  SORT.VALUE = SORT.REC<SORT.ATTR, SORT.I>
  LOCATE SORT.VALUE IN SORT.BASE<1>,1 BY 'AR' SETTING SORT.INDEX ELSE NULL
  SORT.BASE = INSERT(SORT.BASE, 1, SORT.INDEX, 0, SORT.VALUE)
  FOR ATTR.I = 1 TO ATTR.COUNT
    ATTR = ATTR.LIST<ATTR.I>
    ATTR.VALUE = SORT.REC<ATTR, SORT.I>
    DATA.BASE<ATTR.I> = INSERT(DATA.BASE<ATTR.I>, 1, SORT.INDEX, 0,
ATTR.VALUE)
  NEXT ATTR.I
NEXT SORT.I
* Replace the sort record with the sorted values
SORT.REC<SORT.ATTR> = SORT.BASE
FOR ATTR.I = 1 TO ATTR.COUNT
  ATTR = ATTR.LIST<ATTR.I>
  SORT.REC<ATTR> = DATA.BASE<ATTR.I>
NEXT ATTR.I
ORD = SORT.REC
WRITE ORD ON ORDER.BACK, 'SORTED'
STOP

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Jacques G.
Sent: Saturday, February 19, 2005 10:33
To: [email protected]
Subject: Re: [U2] Quicksort ?


Someone posted a Quicksort routine a while back where
dependent elements could also be sorted with the array
that was being sorted.  Could someone repost it please
(or supply a link to where I can find it ?)

Thanks




__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
-------
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/

Reply via email to