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
