PROGRAM sort3

!-- read in three real numbers and PRINT them in ascending order

  IMPLICIT NONE
  REAL :: n1, n2, n3, temp

!-- read the numbers
  PRINT*, 'enter the values to be sorted'
  READ*, n1, n2, n3
  PRINT*, "Input data n1:",n1
  PRINT*, "           n2:",n2
  PRINT*, "           n3:",n3
  
!-- sort the numbers
  IF (n1 > n2) THEN
    temp = n1; n1 = n2; n2 = temp
  ENDIF
  IF (n1 > n3) THEN
    temp = n1; n1 = n3; n3 = temp
  ENDIF
  IF (n2 > n3) THEN
    temp = n2; n2 = n3; n3 = temp
  ENDIF

!-- PRINT the numbers
  PRINT *, "The numbers in ascending order are:"
  PRINT *, n1, n2, n3
  
END PROGRAM sort3
