Kbase P7872: How to sort elements of an array?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/30/2003 |
|
Status: Unverified
GOAL:
How to sort elements of an array?
GOAL:
How to sort a field that contains extents in an ascending format?
FIX:
DEFINE VARIABLE viCounter1 AS INTEGER NO-UNDO.
DEFINE VARIABLE viCounter2 AS INTEGER NO-UNDO.
DEFINE VARIABLE vdtDeliveredDate AS DATE
FORMAT "99/99/9999":U EXTENT 9 NO-UNDO.
DEFINE VARIABLE vdtDeliveredDateAux AS DATE
FORMAT "99/99/9999":U.
ASSIGN vdtDeliveredDate[1] = 12/12/02
vdtDeliveredDate[2] = 10/12/02
vdtDeliveredDate[3] = 11/12/02
vdtDeliveredDate[4] = 08/12/02
vdtDeliveredDate[5] = 05/12/02
vdtDeliveredDate[6] = 01/12/02
vdtDeliveredDate[7] = 03/12/02
vdtDeliveredDate[8] = 02/12/02
vdtDeliveredDate[9] = 07/12/02.
DISPLAY
"Dates shown in a disorganized format:"
SKIP(1)
vdtDeliveredDate
WITH CENTERED NO-BOX DOWN FRAME a 1 COLUMN NO-LABELS.
DO viCounter1 = 1 TO 9:
DO viCounter2 = 1 TO 9:
IF vdtDeliveredDate[viCounter1] < vdtDeliveredDate[viCounter2] THEN
ASSIGN vdtDeliveredDateAux = vdtDeliveredDate[viCounter1]
vdtDeliveredDate[viCounter1] = vdtDeliveredDate[viCounter2]
vdtDeliveredDate[viCounter2] = vdtDeliveredDateAux.
END.
END.
DISPLAY
"Dates ordered in an ascending format:"
SKIP(1)
vdtDeliveredDate
WITH CENTERED NO-BOX DOWN ROW 11 FRAME b 1 COLUMN NO-LABELS.