Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 10309
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 OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us