Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 7936
Location: Bellevue, IA

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 Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us