This doesn't print out a thing in the template. It is as if the @sorted in empty.foreach $homework (@homeworks) { $query = "SELECT PointValue,DueDate FROM Homework WHERE ClassID = +\'$courseID\' AND SectionID = \'$sectionID\' AND InstructorID = $ins +tructorID 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] } ke +ys %homeworkHash; # I then pass the @sorted to a template under the name homeworks and i +n the template I use this to print out the hash. [% FOREACH key IN homeworks %] <th valign="bottom" class="Homework"><span id="points">[% key +%]</span><br>[% homework.$key.0 %]<br>[% homework.$key.1 %]</th> [% END %]
In reply to Re^2: sorting hash by value when value is an array ref
by beachguy82
in thread sorting hash by value when value is an array ref
by beachguy82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |