6 * asort - typesafe array sort (qsort)
8 * qsort() is the standard routine for sorting an array of objects.
9 * Unfortunately, it has two problems:
10 * 1) It isn't typesafe,
11 * 2) The comparison function doesn't take a context pointer.
15 * License: LGPL (v2.1 or any later version)
16 * Author: Rusty Russell <rusty@rustcorp.com.au>
19 * #include <ccan/asort/asort.h>
23 * static int cmp(char *const *a, char *const *n, bool *casefold)
26 * return strcasecmp(*a, *n);
28 * return strcmp(*a, *n);
31 * int main(int argc, char *argv[])
33 * bool casefold = false;
37 * fprintf(stderr, "Usage: %s [-i] <list>...\n"
38 * "Sort arguments (-i = ignore case)\n",
43 * if (strcmp(argv[1], "-i") == 0) {
48 * asort(&argv[1], argc-1, cmp, &casefold);
49 * for (i = 1; i < argc; i++)
50 * printf("%s ", argv[i]);
55 int main(int argc, char *argv[])
60 if (strcmp(argv[1], "depends") == 0) {
61 printf("ccan/order\n");
64 if (strcmp(argv[1], "testdepends") == 0) {
65 printf("ccan/array_size\n");