@@ -3605,19 +3605,13 @@ sub fill_project_list_info {
36053605 return @projects ;
36063606}
36073607
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
36103610sub print_sort_th {
3611- my ($str_sort , $name , $order , $key , $header , $list ) = @_ ;
3612- $key ||= $name ;
3611+ my ($name , $order , $header ) = @_ ;
36133612 $header ||= ucfirst ($name );
36143613
36153614 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- }
36213615 print " <th>$header </th>\n " ;
36223616 } else {
36233617 print " <th>" .
@@ -3627,14 +3621,6 @@ sub print_sort_th {
36273621 }
36283622}
36293623
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-
36383624sub git_project_list_body {
36393625 my ($projlist , $order , $from , $to , $extra , $no_header ) = @_ ;
36403626
@@ -3645,20 +3631,29 @@ sub git_project_list_body {
36453631 $from = 0 unless defined $from ;
36463632 $to = $#projects if (!defined $to || $#projects < $to );
36473633
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+
36483647 print " <table class=\" project_list\" >\n " ;
36493648 unless ($no_header ) {
36503649 print " <tr>\n " ;
36513650 if ($check_forks ) {
36523651 print " <th></th>\n " ;
36533652 }
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' );
36623657 print " <th></th>\n " . # for links
36633658 " </tr>\n " ;
36643659 }
0 commit comments