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

Sort behaving strange!!


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Jun 18, 2009 9:36 pm
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

Moderator Emeritus


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

PostPosted: Fri Jun 19, 2009 12:28 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
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
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top