]> thyrsus.com Git - comparator.git/commitdiff
Better sorting for the report.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 13 Sep 2003 20:19:21 +0000 (20:19 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 13 Sep 2003 20:19:21 +0000 (20:19 +0000)
report.c

index 72b05917e79adaef9e1d9353fa1c057974b507e4..1bbfad786042ce2d825436513d5888c42e05bb26 100644 (file)
--- a/report.c
+++ b/report.c
@@ -273,12 +273,25 @@ static int sortmatch(const void *a, const void *b)
 {
     struct sorthash_t *s = ((struct match_t *)a)->matches;
     struct sorthash_t *t = ((struct match_t *)b)->matches;
+    int i;
 
-    int cmp = strcmp(s->file->name, t->file->name);
-    if (cmp)
-       return(cmp);
-    else
-       return(s->hash.start - t->hash.start);
+    /* first sort by file */
+    for (i = 0; i < ((struct match_t *)a)->nmatches; i++)
+    {
+       int cmp = strcmp(s[i].file->name, t[i].file->name);
+
+       if (cmp)
+           return(cmp);
+    }
+
+    /* then sort by start line number */
+    for (i = 0; i < ((struct match_t *)a)->nmatches; i++)
+    {
+       int cmp = s->hash.start - t->hash.start;
+
+       if (cmp)
+           return(cmp);
+    }
 
     return(0);
 }