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
 
Why is SORT rearranging records that are already sorted?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Why is SORT rearranging records that are already sorted?
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: 1109
Location: Oostende, Belgium

PostPosted: Wed Jan 24, 2018 10:40 pm    Post subject:
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: 711
Location: Pennsylvania

PostPosted: Wed Jan 24, 2018 10:50 pm    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10478
Location: italy

PostPosted: Wed Jan 24, 2018 10:57 pm    Post subject: Reply to: Why is SORT rearranging records that are already sorted?
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: 2020
Location: UK

PostPosted: Thu Jan 25, 2018 2:55 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm

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