Page 1 of 1

Sorting Alphanumeric

PostPosted: Thu May 07, 2009 2:39 pm
by kumar4567
Hi all,

I need to achieve the following using Sort card.

I/P:
0000034R098765A0012AS
0000034R0987659999999
000003400123340001010
000003499999999999999

I want to sort it in such a way that the record with '9999' comes at top. The first 7 places corresponds to ID1, next 7 places ID2, next 4 places ID3 and final 3 places ID4. The problem is that ID2, ID3, ID4 are all alphanumeric as mentioned above. The final O/P should look like...

O/P:
000003499999999999999
0000034R0987659999999
0000034R098765A0012AS
000003400123340001010

Please help me. Thanks in advance !!!

Regards,
Kumar

Re: Sorting Alphanumeric

PostPosted: Thu May 07, 2009 9:25 pm
by Frank Yaeger
Your description of what you want to do is not clear.

You describe 21 bytes in your layout but your records show 22 bytes. So I'm guessing ID4 has a length of 4, not 3 as you stated.

I think you want to sort descending on ID4, but it's not clear what other fields you want to sort on and in what sequence (ascending or descending).

This DFSORT SORT statement would give you the output you say you want, but you haven't shown a good enough sample of input and output records for me to determine if that's what you really want to do:

  SORT FIELDS=(18,4,CH,D,1,17,CH,D)     


If that's not what you want, then describe how you want to sort on the other fields.