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: 10232
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 Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


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