× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Another solution is to use RpgMap (github.com/jerps/RpgMap).
It supports composite keys, e.g. rm_v( rm_i(-6) : rm_a('A') ) specifies a
composite key (a vector) with integer -6 and character 'A'.

// make new map m
m = rm_m();

// insert key/item pairs (only the keys are relevant so the items are
null).
// rm_( x : 0 ) specifies that object x (a map or a value) has reversed
order (reversed order could also be specified with setting a specific
compare function).
rm_ins(m
: rm_( rm_v( rm_i( -6 ) : rm_a( 'A' ) ) : 0) : null
: rm_( rm_v( rm_i( -3 ) : rm_a( 'Y'' ) ) : 0) : null
: rm_( rm_v( rm_i( 5 ) : rm_a( 'G' ) ) : 0) : null
: rm_( rm_v( rm_i( -4 ) : rm_a( 'H' ) ) : 0) : null
: rm_( rm_v( rm_i( 2 ) : rm_a( 'D' ) ) : 0) : null
: rm_( rm_v( rm_i( 0 ) : rm_a( 'B' ) ) : 0) : null
);

// iterate through the keys to display them
c = rm_sll(rm_cur(m));
dow rm_rdn(c);

dsply ( %char(rm_i_(rm__i(rm_key(m):1))) + ' - ' + rm_a_(rm__i(rm_key(m):2))
);

enddo;

Btw, an alternative to reversed order would be to simply iterate from the
end to the start.








On Wed, Jun 20, 2018 at 11:43 PM, Troy Foster <tfoster@xxxxxxxxxx> wrote:

I have looked an I can't find a solution. This is example of what I am
trying to accomplish. Is it possible? Does anyone have an example?

I get this when it sorts.
NB(1) = 5.
NB(2) = 2.
NB(3) = 0.
NB(4) = -6.
NB(5) = -4.
NB(6) = -3.
NB(7) = 0.
NB(8) = 0.
NB(9) = 0.
NB(10) = 0.

I want to get:

NB(1) = 5.
NB(2) = 2.
NB(3) = 0.
NB(4) = -3.
NB(5) = -4.
NB(6) = -6.
NB(7) = 0.
NB(8) = 0.
NB(9) = 0.
NB(10) = 0.

This is a sample of the code that I use. I

H BNDDIR('QC2LE')

D qsort PR ExtProc('qsort')
D base * value
D num 10U 0 value
D width 10U 0 value
D compare * procptr value

D LastName PR 10I 0
D parm1 like(name)
D parm2 like(name)

D name s 5
D num_names s 10i 0

d ds
D DS 5 dIM(10)
D NB 1s 0 OVERLAY(DS:*NEXT) INZ(0)
d A 1 OVERLAY(DS:*NEXT) INZ(' ')

c eval NB(1) = -6
c eval NB(2) = -3
c eval NB(3) = 5
c eval NB(4) = -4
c eval NB(5) = 2
c eval NB(6) = 0
c Eval A(1) = 'A'
c Eval A(2) = 'Y'
c Eval A(3) = 'G'
c Eval A(4) = 'H'
c Eval A(5) = 'D'
c Eval A(6) = 'B'

c eval num_names = 6

c callp qsort(%addr(NB): num_names:
c %size(name): %paddr('LASTNAME'))
c eval *inlr = *on

P LastName B
D LastName PI 10I 0
D parm1 like(name)
D parm2 like(name)

c select
c when parm1 < parm2
c return 1
c when parm1 > parm2
c return -1
c other
c return 0
c endsl

P E
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.
`
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.