@@ -3605,19 +3605,13 @@ sub fill_project_list_info {
3605
3605
return @projects ;
3606
3606
}
3607
3607
3608
- # print 'sort by' <th> element, either sorting by $key if $ name eq $order
3609
- # (changing $list), or generating 'sort by $name' replay link otherwise
3608
+ # print 'sort by' <th> element, generating 'sort by $name' replay link
3609
+ # if that order is not selected
3610
3610
sub print_sort_th {
3611
- my ($str_sort , $name , $order , $key , $header , $list ) = @_ ;
3612
- $key ||= $name ;
3611
+ my ($name , $order , $header ) = @_ ;
3613
3612
$header ||= ucfirst ($name );
3614
3613
3615
3614
if ($order eq $name ) {
3616
- if ($str_sort ) {
3617
- @$list = sort {$a -> {$key } cmp $b -> {$key }} @$list ;
3618
- } else {
3619
- @$list = sort {$a -> {$key } <=> $b -> {$key }} @$list ;
3620
- }
3621
3615
print " <th>$header </th>\n " ;
3622
3616
} else {
3623
3617
print " <th>" .
@@ -3627,14 +3621,6 @@ sub print_sort_th {
3627
3621
}
3628
3622
}
3629
3623
3630
- sub print_sort_th_str {
3631
- print_sort_th(1, @_ );
3632
- }
3633
-
3634
- sub print_sort_th_num {
3635
- print_sort_th(0, @_ );
3636
- }
3637
-
3638
3624
sub git_project_list_body {
3639
3625
my ($projlist , $order , $from , $to , $extra , $no_header ) = @_ ;
3640
3626
@@ -3645,20 +3631,29 @@ sub git_project_list_body {
3645
3631
$from = 0 unless defined $from ;
3646
3632
$to = $#projects if (!defined $to || $#projects < $to );
3647
3633
3634
+ my %order_info = (
3635
+ project => { key => ' path' , type => ' str' },
3636
+ descr => { key => ' descr_long' , type => ' str' },
3637
+ owner => { key => ' owner' , type => ' str' },
3638
+ age => { key => ' age' , type => ' num' }
3639
+ );
3640
+ my $oi = $order_info {$order };
3641
+ if ($oi -> {' type' } eq ' str' ) {
3642
+ @projects = sort {$a -> {$oi -> {' key' }} cmp $b -> {$oi -> {' key' }}} @projects ;
3643
+ } else {
3644
+ @projects = sort {$a -> {$oi -> {' key' }} <=> $b -> {$oi -> {' key' }}} @projects ;
3645
+ }
3646
+
3648
3647
print " <table class=\" project_list\" >\n " ;
3649
3648
unless ($no_header ) {
3650
3649
print " <tr>\n " ;
3651
3650
if ($check_forks ) {
3652
3651
print " <th></th>\n " ;
3653
3652
}
3654
- print_sort_th_str(' project' , $order , ' path' ,
3655
- ' Project' , \@projects );
3656
- print_sort_th_str(' descr' , $order , ' descr_long' ,
3657
- ' Description' , \@projects );
3658
- print_sort_th_str(' owner' , $order , ' owner' ,
3659
- ' Owner' , \@projects );
3660
- print_sort_th_num(' age' , $order , ' age' ,
3661
- ' Last Change' , \@projects );
3653
+ print_sort_th(' project' , $order , ' Project' );
3654
+ print_sort_th(' descr' , $order , ' Description' );
3655
+ print_sort_th(' owner' , $order , ' Owner' );
3656
+ print_sort_th(' age' , $order , ' Last Change' );
3662
3657
print " <th></th>\n " . # for links
3663
3658
" </tr>\n " ;
3664
3659
}
0 commit comments