holli has asked for the wisdom of the Perl Monks concerning the following question:
The names are in the YYYYMMDD-format. In a template I iterate over this directory usingC:\xampp\htdocs\messages 20050121.html 20050122.html 20050123.html 20050124.html 20050125.html 20050126.html 20050127.html 20050128.html 20050129.html 20050130.html 20050913.html 20051124.html
I also tried<table cellpadding="0" cellspacing="0"> <tr> <td colspan="2"> [% USE dumper(indent=0, pad="<br>") %] [% USE dir = Directory('/xampp/htdocs/messages') %] [% FOREACH file = dir.files.sort %] <p>[% file.name %]</p> <p>[%# file.contents %]</p> [% END %] </td> </tr> </table>
But none of them seems to work, because in the output the files are in this order:[% FOREACH file = dir.files.sort(file.name) %] [% FOREACH file = dir.files.sort(name) %]
As you can see they are not sorted. Anyone has a clue why?20050128.html 20050127.html 20050126.html 20050125.html 20050124.html 20050123.html 20050122.html 20050121.html 20051124.html 20050913.html 20050130.html 20050129.html
Don't you call that premature optimization? ;([% FOREACH file = dir.files %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort in Template Toolkit broken?
by davorg (Chancellor) on Nov 24, 2005 at 17:04 UTC | |
by holli (Abbot) on Nov 24, 2005 at 17:06 UTC | |
|
Re: Sort in Template Toolkit broken?
by Anonymous Monk on Nov 25, 2005 at 14:06 UTC |