!
! this section of code ranks the order 
! of elements of array A into array B
!
!

A(NumEle + 1) = 0
CurrMax = 100000

DO J = 1 , NumEle
   NextMax = NumEle + 1
   DO I = 1, NumEle
      IF( A(I) > A(NextMax) .AND. A(I) < CurrMax) THEN
          NextMax = I
      END IF
   END DO
   B(J) = NextMax
   CurrMax = A(NextMax)
END DO

