Code for Program describes sorting technique in Cobol
#--------------------------------------------------------------------------------#
INPUT FILE - SORT.INP
#--------------------------------------------------------------------------------#
prem 15
harshad 17
khilan 42
krish 44
hemal 74
shashank 72
nita 34
amisha 01
gediya 10
vd 06
#--------------------------------------------------------------------------------#
CODE FILE - SORT.CBL
#--------------------------------------------------------------------------------#
IDENTIFICATION DIVISION.
PROGRAM-ID. SORT1.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT UNSORTED-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT WORK-FILE ASSIGN TO SYSWORK.
SELECT SORTED-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD UNSORTED-FILE
VALUE OF FILE-ID IS "SORT.INP".
01 IN-REC.
05 IN-NAME PIC X(7).
05 FILLER PIC XX.
05 IN-AGE PIC 99.
SD WORK-FILE.
01 WORK-REC.
05 FILLER PIC X(9).
05 WORK-AGE PIC 99.
FD SORTED-FILE
VALUE OF FILE-ID IS "SORT.OUT".
01 OUT-REC PIC X(80).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
SORT WORK-FILE
ON DESCENDING KEY WORK-AGE
USING UNSORTED-FILE
GIVING SORTED-FILE.
STOP RUN.
#--------------------------------------------------------------------------------#
OUPUT FILE - SORT.OUT
#--------------------------------------------------------------------------------#
hemal 74
shashank 72
krish 44
khilan 42
nita 34
harshad 17
prem 15
gediya 10
vd 06
amisha 01