5 * asort - typesafe array sort (qsort)
7 * qsort() is the standard routine for sorting an array of objects.
8 * Unfortunately, it has two problems:
9 * 1) It isn't typesafe,
10 * 2) The comparison function doesn't take a context pointer.
17 * #include <ccan/asort/asort.h>
21 * static int cmp(const char **a, const char **n, bool *casefold)
24 * return strcasecmp(*a, *b);
26 * return strcmp(*a, *b);
29 * int main(int argc, char *argv[])
31 * bool casefold = false;
35 * fprintf(stderr, "Usage: %s [-i] <list>...\n"
36 * "Sort arguments (-i = ignore case)\n",
41 * if (strcmp(argv[1], "-i") == 0) {
46 * asort(&argv[1], argc-1, cmp, &casefold);
47 * for (i = 1; i < argc; i++)
48 * printf("%s ", argv[i]);
53 int main(int argc, char *argv[])
58 if (strcmp(argv[1], "depends") == 0) {
59 printf("ccan/typesafe_cb\n");
60 printf("ccan/array_size\n");