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 behaving strange!!

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
candyboy

New User


Joined: 13 Nov 2006
Posts: 10

PostPosted: Thu Jun 18, 2009 9:29 pm    Post subject: Sort behaving strange!!
Reply with quote

Hi,

I am facing this strange issue: I have data in input file as:


ID S# E# R# DATE
(Char 15) (s9(8) COMP-3)
03111111, 172, 1, A 20070904
03222222, 31, 10, B 19920723
03222222, 31, 9, K 19991201
03222222, 31, 8, K 20001201
03222222, 31, 7, K 20011201
03222222, 31, 6, K 20021201
03222222, 31, 5, K 20031201
03222222, 31, 4, K 20041201
03222222, 31, 3, K 20051201
03222222, 31, 2, K 20061201
03222222, 31, 1, K 20070817
03222222, 100, 1, A 20070817

03444444, 106, 1, A 20070827

I am sorting the above file based on field ID & DATE in ascending order. The two rows marked in red have the same value of sort key.
When I sort the complete file containing many other IDs (including the above 3), the order of rows highlighted in red changes. But when
I extract only this ID records to a different input file and run same sort on it, the order remains same. Any idea why this is happening?
I want the order to remain same if the sort key is same for two entries. My sort card is like: SORT FIELDS=(1,15,CH,A,31,5,PD,A) where
1,15 is ID and 31,5 is date.

Thanks CB
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Jun 18, 2009 9:36 pm    Post subject: Reply to: Sort behaving strange!!
Reply with quote

usually the sort order for duplicate keys is unpredictable,
the only option for duplicate keys is to have sort keep them in the input sequence
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: Fri Jun 19, 2009 12:28 am    Post subject:
Reply with quote

Hello,

Unless you tell the sort otherwise, the sorting is only done on the named sort key(s). Sequence of results within a key is unpredictable.

If you want the data to remain in the input sequence within a key, try EQUALS on your control statement.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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