|
|
1.1 root 1:
2: typedef struct {
3: int weight;
4: char *string;
5: } Object;
6:
7: #define Lt(a,b) ((a).weight < (b).weight)
8:
9: #define sort(a,n) ptsort(a, a+n-1)
10:
11: ptsort(l, m)
12: Object *l, *m;
13: {
14: register Object *i, *j; Object x, t;
15: while (l < m) {
16: i = l; j = m;
17: x = i[(j-i)/2];
18: while (i <= j) {
19: while (Lt(*i, x)) i++;
20: while (Lt(x, *j)) j--;
21: if (i <= j) {
22: t = *i;
23: *i++ = *j;
24: *j-- = t;
25: }
26: }
27: if (j-l <= m-i) {
28: ptsort(l, j);
29: l = i;
30: } else {
31: ptsort(i, m);
32: m = j;
33: }
34: }
35: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.