program PIKSRT
use sep
implicit none

  real                  :: r1(200,2),a,b
  real                  :: arr(200,3)
  integer               :: i,j,k

  call sep_init()
  call sep_begin_prog()
  call Random_Number(r1)
  arr(:,1:2)=r1

 do k=1,2
  do i=1,200
     arr(i,3)=real(i)
  end do
  do j=2, 200
    a=arr(j,k)
    b=arr(j,3)
    do i=j-1,1,-1
      if (arr(i,k)<=a) goto 10
      ARR(i+1,3)=arr(i,3)
      ARR(i+1,k)=arr(i,k)
    end do
    i=0
10  ARR(i+1,3)=b
    ARR(i+1,k)=a
  end do
do i=1,200
   write (0,*) k,arr(i,k), arr(i,3)
end do
end do

!      SUBROUTINE PIKSRT(N,ARR)
!      DIMENSION ARR(N)
!      DO 12 J=2,N
!        A=ARR(J)
!        DO 11 I=J-1,1,-1
!          IF(ARR(I).LE.A)GO TO 10
!          ARR(I+1)=ARR(I)
!11      CONTINUE
!        I=0
!10      ARR(I+1)=A
!12    CONTINUE
!      RETURN
!      END

  
   call sep_end_prog()
END program
