IDENTIFICATION DIVISION.
       PROGRAM-ID.  BUBBLE.
       AUTHOR. GROCER.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  TABLE-IN PIC 9(5) VALUE 56234.
       01  RDF-TABLE-IN REDEFINES TABLE-IN.
           05  TAB-SLOT PIC 9 OCCURS 5 TIMES.
       01  SUB1      PIC 9  VALUE 0.
       01  SUB2      PIC 9  VALUE 0.
       01  END-PT    PIC 9  VALUE 5.
       01  FLIP-CT   PIC 9  VALUE 9.
       01  HOLD-SLOT PIC 9  VALUE 0.
       01  RESPOND   PIC X  VALUE SPACES.
       PROCEDURE DIVISION.
       MAINLINE.
           PERFORM B-100-PROCESS.
           STOP RUN.
       B-100-PROCESS.
           PERFORM B-200-SORT
               UNTIL END-PT = 1 OR FLIP-CT = 0.
           DISPLAY TABLE-IN.
           ACCEPT RESPOND.
       B-200-SORT.
           MOVE 1 TO SUB1.
           MOVE 2 TO SUB2.
           MOVE 0 TO FLIP-CT
           PERFORM B-300-PASS
               UNTIL SUB2 > END-PT.
           SUBTRACT 1 FROM END-PT.
       B-300-PASS.
           IF TAB-SLOT (SUB1) > TAB-SLOT (SUB2)
               MOVE TAB-SLOT (SUB1) TO HOLD-SLOT
               MOVE TAB-SLOT (SUB2) TO TAB-SLOT (SUB1)
               MOVE HOLD-SLOT TO TAB-SLOT (SUB2)
               ADD 1 TO FLIP-CT.
           ADD 1 TO SUB1.
           ADD 1 TO SUB2.