Metropoli BBS
VIEWER: iorder.c MODE: TEXT (ASCII)
/* Copyright (C) 1992 by Thomas Glen Smith.  All Rights Reserved. */
/* iorder APL2 V1.0.0 **************************************************
* Called by scalax to sort in integer variable into ascending sequence.*
***********************************************************************/
#define INCLUDES APLCB
#include "includes.h"
void iorder(rite)
Aplcb rite;
{
	Aplcb indxsub();
	int isign(),signum();
	int a,b,i,*ip,j,k,l,m,n,*op,p,q,t;

	if (rite->aplcount < 2)
		return;
	ip = rite->aplptr.aplint;
     n = rite->aplcount;
	m = n/2;
	while (m) {
		k = n-m;
		for (j=0; j<k; j++) {
			i = j;
			do {
				l = i + m;
				a = *(ip + i);
				b = *(ip + l);
                    if (a > b) {
                    	*(ip + i) = b;
                         *(ip + l) = a;
                    }
				i -= m;
			} while (i >= 0);
		}
		m /= 2;
	}
}
[ RETURN TO DIRECTORY ]