
SUBROUTINE sort2_dp(arr,slave)
  USE nrtype; USE nrutil, ONLY : assert_eq
  USE nr, ONLY : indexx
  IMPLICIT NONE
  REAL(DP), DIMENSION(:), INTENT(INOUT) :: arr,slave
  INTEGER(I4B) :: ndum
  INTEGER(I4B), DIMENSION(size(arr)) :: index
  ndum=assert_eq(size(arr),size(slave),'sort2')
  call indexx(arr,index)
  arr=arr(index)
  slave=slave(index)
END SUBROUTINE sort2_dp

SUBROUTINE sort2_sp(arr,slave)
  USE nrtype; USE nrutil, ONLY : assert_eq
  USE nr, ONLY : indexx
  IMPLICIT NONE
  REAL(SP), DIMENSION(:), INTENT(INOUT) :: arr,slave
  INTEGER(I4B) :: ndum
  INTEGER(I4B), DIMENSION(size(arr)) :: index
  ndum=assert_eq(size(arr),size(slave),'sort2')
  call indexx(arr,index)
  arr=arr(index)
  slave=slave(index)
END SUBROUTINE sort2_sp
