Page 1 of 1

Sorting not giving desired output

PostPosted: Sat Oct 25, 2008 11:54 pm
by mani_parashar
Hi All,

I have specific issue related to sort,as it is not giving a desired output.

Input File

John    1080101   John    1080101   
He                John,   1080101
Is                John,   1080101 
a                 John,   1080101   
good              John,   1080101
boy.              John,   1080101
Donna   1070101   Donna   1070101   
She               Donna,  1070101
Is                Donna,  1070101 
a                 Donna,  1070101   
Queen             Donna,  1070101



The above file needs to be sorted in increasing order of name (Maximum 7 bytes long,1 byte of ",") (starts @42 byte) and decreasing order date of birth(starts @52 byte).

Desired Output

Donna   1070101   Donna   1070101   
She               Donna,  1070101
Is                Donna,  1070101 
a                 Donna,  1070101   
Queen             Donna,  1070101
John    1080101   John    1080101   
He                John,   1080101
Is                John,   1080101 
a                 John,   1080101   
good              John,   1080101
boy.              John,   1080101




Please consider that file can extended to 1000(set) of records of same pattern.

I used the following sort control card

  SORT FIELDSs =(42,8,CH,A,52,8,ZD,D)


Above sort resulted
Donna   1070101   Donna   1070101   
Queen             Donna,  1070101
a                 Donna,  1070101   
Is                Donna,  1070101 
She               Donna,  1070101
John    1080101   John    1080101
boy.              John,   1080101
good              John,   1080101
a                 John,   1080101
Is                John,   1080101
He                John,   1080101

Please suggest what happened wrong in the sort control card,or is it that all the records being same at that specific position sort puts it in the any order (all being equivalent).

Thanks,
Mani

Re: Sorting not giving desired output

PostPosted: Sun Oct 26, 2008 12:03 am
by dick scherrer
Hello,

You only specified 2 sort keys, so the sort only sorted on those 2 keys. Within the sorted keys, the sequence is unpredictable.

If you want the data to remain in the input order within the sort key(s), specify EQUALS.

Suggest only using EQUALS when the original sequence is required as it can degrade performance.

Re: Sorting not giving desired output

PostPosted: Sun Oct 26, 2008 2:34 pm
by mani_parashar
Thanks D.Sch,

Correct me I am wrong,you want my sort card should now look like this

  OPTION EQUALS
  SORT FIELDS=(42,8,CH,A,52,8,ZD,D)


Please suggest.

Thanks,
Mani

Re: Sorting not giving desired output

PostPosted: Sun Oct 26, 2008 2:49 pm
by dick scherrer
Hello,

Yes, that should work.

Also

  SORT FIELDS=(42,8,CH,A,52,8,ZD,D),EQUALS


should provide the same result.

Good luck :)

d