# How to SORT digits first then Characters

Author Message
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

 Posted: Wed Nov 27, 2013 4:23 pm Hi, My requirement is if I have c,d,b,1,a,3,2,4 then after sorting I should get 1,2,3,4,a,b,c,d. but since in hexadecimal code digits comes after the alphabets I always get like a,b,c,d,1,2,3,4. Can someone help me out please?
Pandora-Box

Global Moderator

Joined: 07 Sep 2006
Posts: 1590
Location: Andromeda Galaxy

Posted: Wed Nov 27, 2013 4:46 pm

Try this

 Code: //STEP0100 EXEC PGM=SORT //SYSOUT   DD SYSOUT=* //SORTIN   DD * C D B 1 A 3 2 4 //SORTOUT  DD SYSOUT=* //SYSIN    DD *   INREC IFTHEN=(WHEN=(1,1,CH,LT,C'1'),OVERLAY=(81:C'2'))   SORT FIELDS=(81,1,CH,A,1,1,CH,A)
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

 Posted: Wed Nov 27, 2013 4:59 pm No, its not working
Pandora-Box

Global Moderator

Joined: 07 Sep 2006
Posts: 1590
Location: Andromeda Galaxy

 Posted: Wed Nov 27, 2013 5:06 pm Can you please post the output you had got with the code?
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

 Posted: Wed Nov 27, 2013 5:18 pm I have got the same input sequence in the output. Sorting did not happen at all. I got below output: B 1 3 C A 2
Pandora-Box

Global Moderator

Joined: 07 Sep 2006
Posts: 1590
Location: Andromeda Galaxy

 Posted: Wed Nov 27, 2013 5:22 pm could you please post your code here?
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

 Posted: Wed Nov 27, 2013 6:02 pm Note that in ASCII numbers come before letters. If you need an ALTernative SEQuence, there are other possibilities.
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

Posted: Wed Nov 27, 2013 6:23 pm

@Pandora-Box- i m using the same code you provided..

 Code: //SORT1     EXEC PGM=SORT //* //SYSOUT   DD SYSOUT=* //SORTIN   DD * B 1 3 C A 2 //SORTOUT  DD SYSOUT=* //SYSIN    DD *   INREC IFTHEN=(WHEN=(1,1,CH,LT,C'1'),OVERLAY=(81:C'2'))   SORT FIELDS=(81,1,CH,A,1,1,CH,A) /*

@Bill: How can I achieve that where i can sort numbers before letters?
expat

Global Moderator

Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

Posted: Wed Nov 27, 2013 6:41 pm

 pankaj1002 wrote: No, its not working

 pankaj1002 wrote: I have got the same input sequence in the output. Sorting did not happen at all. I got below output: B 1 3 C A 2

Don't give us too much information to work with, will you.

Saying that it doesn't work is useless without showing us at least the SYSOUT segment from the job. How do you think that we can possibly help without any information.

I have tried the code supplied by Pandora, and IT DOES WORK

So, please show the SYSOUT segment from your supposedly not working job, as it may be that you ARE NOT using DFSORT, yet requesting a DFSORT solution. All other sort products should be posted in the JCL section of the forum.

Active User

Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

Posted: Wed Nov 27, 2013 6:44 pm

Hi Pankaj,

Try this code -

 Code: //STEP01   EXEC PGM=SORT          //SYSPRINT DD SYSOUT=*            //SYSOUT   DD SYSOUT=*            //SORTIN   DD *                    C                                  D                                  B                                  1                                  A                                  3                                  2                                  4                                  //SORTOUT  DD SYSOUT=*            //SYSIN    DD *                      SORT FIELDS=(1,1,AC,A)

Thanks,
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

 Posted: Wed Nov 27, 2013 7:56 pm Hello, If Pankaj is unwilling to post the requested info, suggest we spend time on other requests . . . d
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

Posted: Wed Nov 27, 2013 8:04 pm

Hi Pankaj,

Try this code -

 Code: //STEP01   EXEC PGM=SORT          //SYSPRINT DD SYSOUT=*            //SYSOUT   DD SYSOUT=*            //SORTIN   DD *                    C                                  D                                  B                                  1                                  A                                  3                                  2                                  4                                  //SORTOUT  DD SYSOUT=*            //SYSIN    DD *                      SORT FIELDS=(1,1,AC,A)

Thanks,

Thanks bodatrinadh, this is working perfect for me.

Thank you all..
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

 Posted: Wed Nov 27, 2013 8:59 pm Hello, Well, ok. . . I would surely want to know what i had done wrong that the original code did not work. Not knowing will very probably be an issue on some other task. I suspect it is the uninitialized value in pos 81 . . . And when several senior people ask for info, it is a very good idea to post it . . .
pankaj1002

New User

Joined: 30 Jul 2012
Posts: 18
Location: India

 Posted: Thu Nov 28, 2013 8:40 pm Hi D.scherrer, Yes, you are right, I checked again my previous code and found some junk characters from 75 byte because of which it was not working earlier..Thanks again..
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13 Installing sort utilities on hercules... DFSORT/ICETOOL 4 How to add 2 digits to COMP-3 file? DFSORT/ICETOOL 11 Sort card help to prepare status report DFSORT/ICETOOL 13 Building a sort key DFSORT/ICETOOL 3
Search our Forums: