View previous topic :: View next topic
|
Author |
Message |
Yvonne1980
New User
Joined: 31 Aug 2010 Posts: 20 Location: Edinburgh
|
|
|
|
I’m not sure why sort is altering the seq of my records, can someone explain the following to me.
I have a two record input file:
Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 40300124 NA0302RMRS zxcv
44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFFDDDE4AA8A
000000004030012400000000000000000000000000000000000000000510302949209735
------------------------------------------------------------------------------
000002 40300124 NA0302 MRS zxcv
44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFF4DDE4AA8A
000000004030012400000000000000000000000000000000000000000510302049209735
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************
|
I’m sorting with the following sort card
Code: |
SORT FIELDS=(01,63,CH,A)
|
Columns 1 through 63 are identical, however SORT flips the two records around. The only difference in the two records is and ‘R’ as opposed to a blank in col 64.
The output file now has record 1 (record with ‘R’ in pos 64) at the bottom ?
Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 40300124 NA0302 MRS zxcv
44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFF4DDE4AA8A
000000004030012400000000000000000000000000000000000000000510302049209735
------------------------------------------------------------------------------
000002 40300124 NA0302RMRS zxcv
44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFFDDDE4AA8A
000000004030012400000000000000000000000000000000000000000510302949209735
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************
|
I’ve even split the two records into two different files and compared them, cols 1 63 are identical. What am I missing ? |
|
Back to top |
|
|
Yvonne1980
New User
Joined: 31 Aug 2010 Posts: 20 Location: Edinburgh
|
|
|
|
Some more puzzling info if anyone is looking at this.
I allocated a FB 80 file with two records, both records have ‘9’s in every column except col 11 which has a ‘R’ in rec 1 and a blank in rec 2:
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
9999999999R999999999999999999999999999999999999999999999999999999999999999999999
9999999999 999999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ******************************** |
I then sort on cols 1 10 with the following sort card
Code: |
SORT FIELDS=(01,10,CH,A) |
This sort ‘behaves’ as I would expect and gives me the following output:
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
9999999999R999999999999999999999999999999999999999999999999999999999999999999999
9999999999 999999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ******************************** |
When I alter the input file to advance the ‘R’ and blank to col 12 as follows:
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
99999999999R99999999999999999999999999999999999999999999999999999999999999999999
99999999999 99999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ******************************** |
and run with sort:
Code: |
SORT FIELDS=(01,11,CH,A) |
It flips the two records and the output looks like:
-
Code: |
---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
99999999999 99999999999999999999999999999999999999999999999999999999999999999999
99999999999R99999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ******************************** |
What’s going on ? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
Yvonne1980
New User
Joined: 31 Aug 2010 Posts: 20 Location: Edinburgh
|
|
|
|
Thanks Enrico |
|
Back to top |
|
|
|