home *** CD-ROM | disk | FTP | other *** search
- sort(a,n)
-
- /* this subroutine performs an in place sort of */
- /* a one dimensional array using the shell-metzner */
- /* method. */
-
- /* a = the array to be sorted to ascending order */
- /* n = the number of elements in the array */
- /* t = temporary element holder for swap */
-
- float a[];
- 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];
- a[j] = a[j+k];
- a[j+k] = t;
-
- }
- }