]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-11-18 03:22:49 by ajt]
authorajt <>
Sat, 18 Nov 2000 11:22:49 +0000 (03:22 -0800)
committerajt <>
Sat, 18 Nov 2000 11:22:49 +0000 (03:22 -0800)
add sortby=count and sortby=alpha to pkgindex.cgi

cgi/pkgindex.cgi

index b4e1a9d9d5e6525832e22c7f80de8f12652b7ae1..f1dea0134a6b2cdf6e14389fdf22538624aab83b 100755 (executable)
@@ -17,12 +17,17 @@ nice(5);
 my %param = readparse();
 
 my $indexon = $param{'indexon'} || 'pkg';
-if ($indexon !~ m/^(pkg|maint|submitter)/) {
+if ($indexon !~ m/^(pkg|maint|submitter)$/) {
     quit("You have to choose something to index on");
 }
 
 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
 my $archive = ($param{'archive'} || "no") eq "yes";
+my $sortby = $param{'sortby'} || 'alpha';
+if ($sortby !~ m/^(alpha|count)$/) {
+    quit("Don't know how to sort like that");
+}
+
 #my $include = $param{'include'} || "";
 #my $exclude = $param{'exclude'} || "";
 
@@ -104,7 +109,13 @@ if ($indexon eq "pkg") {
 }
 
 my $result = "<ul>\n";
-foreach my $x (sort { $sortkey{$a} cmp $sortkey{$b} } keys %count) {
+my @orderedentries;
+if ($sortby eq "count") {
+  @orderedentries = sort { $count{$a} <=> $count{$b} } keys %count;
+} else { # sortby alpha
+  @orderedentries = sort { $sortkey{$a} cmp $sortkey{$b} } keys %count;
+}
+foreach my $x (@orderedentries) {
   $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} " .
             ($count{$x} == 1 ? "bug" : "bugs") . "</li>\n";
 }