h11158
s 00058/00000/00000
d D 1.1 83/01/20 11:11:14 tes 1 0
c date and time created 83/01/20 11:11:14 by tes
e
u
tes
mjb
U
t
T
I 1
subroutine gzsort (n, zarray, narray, flag)
########################################################################
#                                                                      #
#          THIS MATERIAL IS CONFIDENTIAL AND IS FURNISHED UNDER        #
#          A WRITTEN LICENSE AGREEMENT.  IT MAY NOT BE USED,           #
#          COPIED OR DISCLOSED TO OTHERS EXCEPT IN ACCORDANCE          #
#          WITH THE TERMS OF THAT AGREEMENT.                           #
#                                                                      #
#          COPYRIGHT (C) 1982 GRAPHIC SOFTWARE SYSTEMS INC.            #
#          ALL RIGHTS RESERVED.                                        #
#                                                                      #
#     Function: Perform bubble sort on real array (increasing)         #
#                                                                      #
#     Input Parameters:                                                #
#            n      - number of data elements to sort                  #
#            zarray - real array containing elements to be sorted      #
#            flag   - flag for direction of sort (A - ascending, D -   #
#                     descending)                                      #
#                                                                      #
#     Output Parameters:                                               #
#            zarray - real array that has been sorted                  #
#            narray - integer array containing sorted indices of zarray#
#                                                                      #
#     Routines Called:                                                 #
#            None                                                      #
#                                                                      #
########################################################################
integer n, narray(1), flag
real zarray(1)

integer i, j, k
real rtemp1, rtemp2

   for (i = n; i > 1; i = i - 1) {
      for (j = 1; j < i; j = j + 1) {
	 rtemp1 = zarray(j)
	 rtemp2 = zarray(j+1)
	 if (flag == BIGD) {               # descending sort
	    rtemp1 = zarray(j+1)
	    rtemp2 = zarray(j)
	    }
	 if (rtemp1 > rtemp2) {           # compare
	    rtemp1 = zarray(j)            # exchange
	    k = narray(j)
	    zarray(j) = zarray(j+1)       #
	    narray(j) = narray(j+1)
	    zarray(j+1) = rtemp1          #
	    narray(j+1) = k
	    }
         }
      }





return
end
E 1
