9 static void *get_next(const void *a)
11 return ((const struct line *)a)->next;
14 static void set_next(void *a, void *b)
16 ((struct line *)a)->next = b;
19 static int compare_strings(const void *a, const void *b)
21 const struct line *x = a, *y = b;
22 return strcmp(x->text, y->text);
25 int main(int argc, char **argv)
27 struct line *line, *p = NULL, *lines = NULL;
28 struct strbuf sb = STRBUF_INIT;
31 if (strbuf_getwholeline(&sb, stdin, '\n'))
33 line = xmalloc(sizeof(struct line));
34 line->text = strbuf_detach(&sb, NULL);
45 lines = llist_mergesort(lines, get_next, set_next, compare_strings);
48 printf("%s", lines->text);