I have a COBOL program that calculates GPAs on the fly in the OUTPUT section of the program. I have to store these on-the-fly GPAs in a table, and then sort them by school, grade level, GPA total, then student id. I can load my table, but I am not sorting it.
I load the table right after the GPA is calculated on-the-fly. The program is already sorting the basic data that was gathered in the INPUT section (school, grade, student number, and name (GPA is calculated on-the-fly in the OUTPUT section). So my table is being loaded by school, grade level, student id as the data is released from the sort record in the OUTPUT section.
How do I sort my table by school, grade level, GPA, then student number? I've looked at other forums and read about bubble sorts, sort verb, etc, but none of it makes any sense to me. I have read two COBOL books with chapters on tables and sorting. I think I need to do the "bubble sort", but I dont know where to begin. I follow the logic behind it (ascending key): store the 1st value, then check the 2nd value to see if its great than the 1st stored value, if it is, move 2nd value into table slot 2 else move 1st value to table slot 2 and store 2nd value in table slot 1.
Software/Hardware used: iSeries Pwr6, IBM COBOL/400 compiler