/**********************************************************************/
+int compare_files(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)->size < (*f2)->size) {
+ return -1;
+ } else if((*f1)->size > (*f2)->size) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
void print_sorted(struct file_with_size *root) {
struct file_with_size *node;
struct file_with_size **nodes;
nodes[n++] = node;
}
+ qsort(nodes, nb, sizeof(struct file_with_size *), compare_files);
+
for(n = 0; n < nb; n++) {
printf("%u %s\n", nodes[n]->size, nodes[n]->filename);
}