× 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.



You should be able to use my service program as is. It will support
multiple keys and dynamic data. Handles everything for you.


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

Only want to sort the # of data structures loaded, not the entire array.
That is why I was using qsort. I could just build a file and create
logical files and load from the logical. Trying to do it with a
program(without re-writing it completely.

On 6/20/2018 5:23 PM, Booth Martin wrote:

Have you tried:

sorta NB;

sorta A;

?

On 6/20/2018 4:43 PM, Troy Foster 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.