File:  [Research Unix] / researchv9 / cmd / ps / sort.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)


typedef struct {
	int weight;
	char *string;
} Object;

#define Lt(a,b)	((a).weight < (b).weight)

#define sort(a,n)	ptsort(a, a+n-1)

ptsort(l, m)
Object *l, *m;
{
	register Object *i, *j; Object x, t;
	while (l < m) {
		i = l; j = m;
		x = i[(j-i)/2];
		while (i <= j) {
			while (Lt(*i, x)) i++;
			while (Lt(x, *j)) j--;
			if (i <= j) {
				t = *i;
				*i++ = *j;
				*j-- = t;
			}
		}
		if (j-l <= m-i) {
			ptsort(l, j);
			l = i;
		} else {
			ptsort(i, m);
			m = j;
		}
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.