foreach $homework (@homeworks) { $query = "SELECT PointValue,DueDate FROM Homework WHERE ClassID = \'$courseID\' AND SectionID = \'$sectionID\' AND InstructorID = $instructorID AND HomeworkName = \'$homework\'"; $statementHandle = $databaseHandle -> prepare($query); $statementHandle -> execute(); while(@rowArray = $statementHandle -> fetchrow_array()) { $homeworkHash{$homework} = [$rowArray[0],$rowArray[1]]; } } # now the sorting my @sorted = sort { $homeworkHash{$a}[1] cmp $homeworkHash{$b}[1] } keys %homeworkHash; # I then pass the @sorted to a template under the name homeworks and in the template I use this to print out the hash. [% FOREACH key IN homeworks %] [% key %]
[% homework.$key.0 %]
[% homework.$key.1 %] [% END %]