program Sort_N_data implicit none integer :: N , a , I , J real , allocatable , dimension (:) :: di_date(:) real*8 :: data1 , temp open (unit=30 ,file='date3.dat',status='REPLACE') read(*,*) N write(30,*)N allocate(di_date(N)) a=1 do a = 1 , N read(*,*) data1 di_date(a)=data1 end do do I=N-1 , 1 , -1 do J= 1, I if (di_date(J) < di_date(J+1)) then temp=di_date(J) di_date(J)=di_date(J+1) di_date(J+1)=temp end if end do end do I=1 do I =1, N write(*,*) di_date(I) write(30,*) di_date(I) end do write(*,*) "Max = " , di_date(1) write(*,*) "min = " , di_date(N) deallocate (di_date) close(30) write(*,*)"SAVE in 'date3,dat' " stop end program Sort_N_data