home *** CD-ROM | disk | FTP | other *** search
- sort2(a,b,n)
-
- /* this subroutine performs an in place sort of */
- /* a one dimensional array using the shell-metzner */
- /* method. then matches that order in a second array */
-
- /* a = the array to be sorted to ascending order */
- /* b = the second array to be ordered as the first */
- /* n = the number of elements in the array */
- /* t = temporary element holder for swap */
-
- float a[],b[];
- int n;
-
- {
- float t;
- int i,j,k;
-
- for(k=n/2; k>0; k/=2)
- for(i=k; i<n; i++)
- for(j=i-k; j>=0 && a[j] > a[j+k]; j-=k)
- {
- t = a[j]; /* indexing array */
- a[j] = a[j+k];
- a[j+k] = t;
-
- t = b[j]; /* second array */
- b[j] = b[j+k];
- b[j+k] = t;
- }
- }