Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort an array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Jun 02, 2010 10:59 pm    Post subject: Sort an array
Reply with quote

Hi,

I have one requirement in which I have to sort one array which is having 4 fields (say Name, location, account, amount). Now I want to sort the records in such a way that Name should be sorted first, Location should be sorted second, account should be sorted third and amount should be sorted fourth.

For ex:
name location account amount
Simha hyd 2 3000
Simha Pune 1 4000
Simha Mum 3 1000
Raghu Hyd 3 2000
Ravi Pune 1 3000


the ouput should be
Raghu Hyd 3 2000
Ravi Pune 1 3000
Simha hyd 2 3000
Simha Mum 3 1000
Simha Pune 1 4000

This is a CICS module. so I can't use JCL and it's not a DB2 table.

thanks
Simha.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Wed Jun 02, 2010 11:07 pm    Post subject:
Reply with quote

I don't see a question in here. If you are wanting a sort algorithm, Google is your friend. Googling sort algorithm returns 1,370,000 hits.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Jun 02, 2010 11:08 pm    Post subject:
Reply with quote

Have you considered a CICS-maintained data table?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 02, 2010 11:12 pm    Post subject:
Reply with quote

Hello,

One way to get what you want is to put the values into the array "in sequence" rather than loading the array with out-of-sequence values.

Another is to manually sort the array after it is loaded.

Look here (start from the bottom):
http://ibmmainframes.com/viewtopic.php?t=15902
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Jun 02, 2010 11:18 pm    Post subject:
Reply with quote

"One way to get what you want is to put the values into the array "in sequence" rather than loading the array with out-of-sequence values.

Another is to manually sort the array after it is loaded. "

Yes...My response is already loaded with records. Now I want to sort the records (need to consider 4 fields) here. Do I need to sort the records first with name and then sort the same with Location and next sort with Account and final sort with Amout? (there are 4 sorts).
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 02, 2010 11:32 pm    Post subject:
Reply with quote

Hello,

Suggest you look at the link i posted. . . It shows the code to sort an array. You need to define the array to be sorted so that all of the key data is in consecutive bytes - from highest order field to lowest. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us