PROGRAM sort10

!-- read in 10 INTEGERs and sort them from lowest to highest

  IMPLICIT NONE
  INTEGER, DIMENSION(10) :: nums
  INTEGER :: temp, j, k

!-- read in the data
  PRINT *, 'Type ten INTEGERs each on a new line'
  DO j = 1,10
    READ *,nums(j)
  ENDDO

!-- read in the data all on the same line
!  PRINT *, 'Type ten INTEGERs all on the same line'
!  read *,nums

!-- echo the input data
  PRINT *, 'orig nums array = ',nums

!-- sort the numbers into ascending order of magnitude
  L1: DO j = 1,9
  L2:   DO k = j+1,10
           IF (nums(j) > nums(k)) THEN
             temp = nums(k)
             nums(k) = nums(j)
             nums(j) = temp
           ENDIF
        ENDDO L2
      ENDDO L1

!-- write the sorted list
  DO j = 1,10
    PRINT *,'rank ',j,' valus is ',nums(j)
  ENDDO
   
END PROGRAM sort10 
