C C Subroutine ORDER sorts two parallel arrays (WORD and COUNT) using C a simple exchange sort (sinking sort). The arrays are put in C ascending order based on the elements of WORD which consists of C three-letter words. COUNT contains the frequencies of occurrence C of each word. LEN is the number of entries in the two arrays. C SUBROUTINE ORDER (WORD, COUNT, LEN) CHARACTER*3 WORD(200), TWORD INTEGER*2 COUNT(200), LEN INTEGER J, K LOGICAL EXCH J = 1 13 EXCH = .FALSE. C C Loop to do one pass over the arrays, exchanging adjacent entries C as necessary. C DO 11 K = 1, LEN - J IF (WORD(K) .GT. WORD(K+1)) THEN TWORD = WORD(K) WORD(K) = WORD(K+1) WORD(K+1) = TWORD C C Rely on assembly language routine INTEXCH to exchange two entries C in the frequency COUNT array C CALL INTEXCH (COUNT(K), COUNT(K+1)) EXCH = .TRUE. ENDIF 11 CONTINUE J = J + 1 C C Determine if another pass is needed C IF (EXCH) GO TO 13 RETURN END