+static int sortfn(const void *_a, const void *_b)
+{
+ const struct dive *a = *(void **)_a;
+ const struct dive *b = *(void **)_b;
+
+ if (a->when < b->when)
+ return -1;
+ if (a->when > b->when)
+ return 1;
+ return 0;
+}
+
+static void report_dives(void)
+{
+ int i;
+ qsort(dive_table, nr_dives, sizeof(struct dive *), sortfn);
+
+ for (i = 0; i < nr_dives; i++)
+ show_dive(i+1, dive_table[i]);
+}
+