--- loncom/interface/lonprintout.pm 2012/05/28 10:44:42 1.617 +++ loncom/interface/lonprintout.pm 2012/06/07 10:27:26 1.618 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.617 2012/05/28 10:44:42 foxr Exp $ +# $Id: lonprintout.pm,v 1.618 2012/06/07 10:27:26 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1233,6 +1233,22 @@ sub is_code_valid { } } +# +# Compare two students by section (Used to sort by section). +# +# Implicit inputs, +# $a - The first one +# $b - The second one. +# +# Returns: +# a-section cmp b-section +# +sub compare_sections { + my ($u1, $d1, $s1, $n1, $stat1) = split(/:/, $a); + my ($u2, $d2, $s2, $n2, $stat2) = split(/:/, $b); + + return $s1 cmp $s2; +} # Compare two students by name. The students are in the form # returned by the helper: @@ -3103,6 +3119,8 @@ ENDPART if (($helper->{'VARS'}->{'student_sort'} eq 1) && ($helper->{'VARS'}->{'SPLIT_PDFS'} ne "sections")) { @students = sort compare_names @students; + } else { + @students = sort compare_sections @students; } &adjust_number_to_print($helper);