IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sort an array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 02, 2010 11:07 pm
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: 2146
Location: At my coffee table

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

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

Moderator Emeritus


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

PostPosted: Wed Jun 02, 2010 11:12 pm
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):
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
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

Moderator Emeritus


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

PostPosted: Wed Jun 02, 2010 11:32 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top