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

Why is SORT rearranging records that are already sorted?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cschablow

New User


Joined: 23 Jan 2018
Posts: 1
Location: USA

PostPosted: Wed Jan 24, 2018 10:14 pm
Reply with quote

I have several jobs that bring in multiple interface files, some of which have the same value in the sort columns (there's a potential to have additional values), so they are basically already sorted.

The jobs have been updated to always sort the input file, but the files that are already "sorted" are changed:

SORT card:
Code:
SORT  FIELDS=(1,3,CH,A)


Input file:
Code:
********************************* Top of Data *****************
001$CRESER122517 032000    AK80-04   D00000001928          AL09
001$CRESER122517 522090    AK80-04   C00000000964          AL09
001$CRESER122517 290061    AK80-04   C00000000964          AL09
001$CRESER122517 117001    AL09-01   D00000001928          AK80
001$CRESER122517 032000    AK82-04   D00000002122          AL09


Sorted file:
Code:
********************************* Top of Data *****************
001$CRESER122517 032000    AK80-04   D00000001928          AL09
001$CRESER122517 032000    OK06-06   D00000000000          TX46
001$CRESER122517 290061    UT04-04   C00000000000          WY05
001$CRESER122517 117001    WY05-01   D00000000000          UT04
001$CRESER122517 032000    WI02-02   D00000000000          WY05


Does anyone know how to avoid this?

Coded - do it yourself next time
You found the underline tags so using the code tags should be a doddle.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Jan 24, 2018 10:40 pm
Reply with quote

Read about stable and unstable sorts.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Jan 24, 2018 10:50 pm
Reply with quote

SORT FIELDS=(1,3,CH,A) ,EQUALS

This will retain input order on equal keys.

Believe it or not, this is in the manual. icon_redface.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Jan 24, 2018 10:57 pm
Reply with quote

Quote:
A COBOL Mainframe guru,

does not read no steenking manuals
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jan 25, 2018 2:55 am
Reply with quote

Nothing to do with JCL. Moved to DFSort on the assumption that that is your sort product.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
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
Search our Forums:

Back to Top