Code for Program for the SORTING Operation in Cobol
*********************
INPUT FILE - SORT.INP
*********************
PREM06
AMIT01
VISHAL46
SANJAY24
*********************
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
*********************
AMIT 01
PREM 06
SANJAY 24
VISHAL 46