+int compare_nodes(const void *x1, const void *x2) {
+ const struct file_with_size **f1, **f2;
+
+ f1 = (const struct file_with_size **) x1;
+ f2 = (const struct file_with_size **) x2;
+
+ if((*f1)->group_id < (*f2)->group_id) {
+ return -1;
+ } else if((*f1)->group_id > (*f2)->group_id) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+void print_result(struct file_with_size *list1, struct file_with_size *list2) {
+ struct file_with_size *node1, *node2;
+ struct file_with_size **nodes;
+ int nb, n;
+
+ nb = 0;
+ for(node1 = list1; node1; node1 = node1->next) {
+ if(node1->group_id >= 0) { nb++; }
+ }
+
+ if(show_hits) {
+ for(node2 = list2; node2; node2 = node2->next) {
+ if(node2->group_id >= 0) { nb++; }
+ }
+ }
+
+ nodes = safe_malloc(nb * sizeof(struct file_with_size *));
+
+ n = 0;
+ for(node1 = list1; node1; node1 = node1->next) {
+ if(node1->group_id >= 0) {
+ nodes[n++] = node1;
+ }
+ }
+
+ if(show_hits) {
+ for(node2 = list2; node2; node2 = node2->next) {
+ if(node2->group_id >= 0) {
+ nodes[n++] = node2;
+ }
+ }
+ }
+
+ qsort(nodes, nb, sizeof(struct file_with_size *), compare_nodes);
+
+ for(n = 0; n < nb; n++) {
+ print_file(nodes[n]);
+ }
+
+ free(nodes);
+}
+