sort repos before subdirectories

This commit is contained in:
Josh Holtrop 2011-05-17 22:37:46 -04:00
parent 56066a65ae
commit 74c80bebcf

View File

@ -4404,13 +4404,29 @@ sub git_project_list_body {
$to = $#projects if (!defined $to || $#projects < $to);
my %order_info = (
project => { key => 'path', type => 'str' },
project => { key => 'path', type => 'file' },
descr => { key => 'descr_long', type => 'str' },
owner => { key => 'owner', type => 'str' },
age => { key => 'age', type => 'num' }
);
my $oi = $order_info{$order};
if ($oi->{'type'} eq 'str') {
if ($oi->{'type'} eq 'file') {
sub cmp_pnames
{
my @a_p = split(/\//, $a->{$oi->{'key'}});
my @b_p = split(/\//, $b->{$oi->{'key'}});
for (my $i = 0; ; $i++)
{
return 0 if ($i > $#a_p && $i > $#b_p);
my $c = lc($a_p[$i]) cmp lc($b_p[$i]);
return $c if ($i == $#a_p && $i == $#b_p);
return -1 if ($i >= $#a_p);
return 1 if ($i >= $#b_p);
return $c if ($c != 0);
}
}
@projects = sort cmp_pnames @projects;
} elsif ($oi->{'type'} eq 'str') {
@projects = sort {lc($a->{$oi->{'key'}}) cmp lc($b->{$oi->{'key'}})} @projects;
} else {
@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;