View previous topic :: View next topic
|
Author |
Message |
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
"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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|