Sometimes I have trouble with sorting hashes. For example, the following TT code:

<table>
[% FOREACH sccs = s_to_c.sort %]
  <tr>
    <td>[% sccs %]</td>
[%    FOREACH code = s_to_c.$sccs.sort %]
    <td>[% code %] ([% s_to_c.$sccs.$code %])</td>

[%    END %]
  </tr>

[% END %]
</table>

(s_to_c is a hash) produces this output:

<table>  <tr>
    <td>d.2.1.3</td>    <td>1.10.530.40 (45)</td>
  </tr>
  <tr>
    <td>b.1.1.1</td>    <td>2.60.40.10 (4)</td>
  </tr>
  <tr>
    <td>a.45.1.1</td>    <td>1.10.490.10 (1)</td>
  </tr>
  <tr>
    <td>a.1.1.2</td>    <td>1.10.490.10 (12)</td>
  </tr>
  <tr>
    <td>c.37.1.8</td>    <td>3.40.50.300 (1)</td>
  </tr>
  <tr>
    <td>b.74.1.1</td>    <td>3.10.200.10 (1)</td>
  </tr>
SNIP

which doesn't seem to be sorted in order of the hash key $sccs (i.e. the order is d.2.1.3 - b.1.1.1 - a.45.1.1 - a.1.1.2 - c.37.1.8 - b.74.1.1 whereas I would have expected a.1.1.2 - a.45.1.1 - b.1.1.1 - b.74.1.1 - c.37.1.8 - d.2.1.3 Can anybody see what I'm doing wrong?

Thanks, Dave


_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to