in reply to Re: sorting hash by value when value is an array ref
in thread sorting hash by value when value is an array ref
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 %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: sorting hash by value when value is an array ref
by jdporter (Paladin) on Nov 16, 2004 at 03:06 UTC | |
by beachguy82 (Novice) on Nov 16, 2004 at 03:15 UTC | |
by beachguy82 (Novice) on Nov 16, 2004 at 03:23 UTC | |
by beachguy82 (Novice) on Nov 16, 2004 at 04:24 UTC | |
by Anonymous Monk on Nov 23, 2004 at 22:10 UTC |