title: Sort array with smarty
body: <p>I need to sort an array with smarty. I try to use <a href="http://www.smarty.net/forums/viewtopic.php?p=23628#23628" rel="nofollow noreferrer">this code</a> :</p>
  
  <p>My foreach:</p>
  
  <pre><code> {foreach $hooks-&gt;addblock as $addblock}
    &lt;ul&gt;
    {foreach $addblock|@sortby:"prio" as $value}
      {$value@key}: {$value}
    {/foreach}
    &lt;/ul&gt;
   {/foreach}
  </code></pre>
  
  <p>The var_dump of <code>$hooks-&gt;addblock</code>:</p>
  
  <pre><code>array(5) {
    ["filed_1"]=&gt;
    array(5) {
      ["id"]=&gt;
      string(7) "filed_1"
      ["title"]=&gt;
      string(6) "filed1"
      ["field"]=&gt;
      string(20) "This is test filed 1"
      ["size"]=&gt;
      int(740)
      ["prio"]=&gt;
      int(7)
    }
    ["filed_2"]=&gt;
    array(5) {
      ["id"]=&gt;
      string(7) "filed_2"
      ["title"]=&gt;
      string(6) "filed2"
      ["field"]=&gt;
      string(20) "This is test filed 2"
      ["size"]=&gt;
      int(740)
      ["prio"]=&gt;
      int(6)
    }
  </code></pre>
  
  <p>So, I want to sort array by value <code>prio</code> (num) ascending, but it does not come out properly!<br>
  Here the result:<br>
  <img src="https://i.stack.imgur.com/JCURB.png" alt="Output smarty"></p>
  
  <p>I would like the line "field_2" be first. But I not find a solution.</p>
  
  <p>This is the modifier (modifier.sortby.php): <a href="http://www.smarty.net/forums/viewtopic.php?p=23628#23628" rel="nofollow noreferrer">http://www.smarty.net/forums/viewtopic.php?p=23628#23628</a>
  I also have a recurring error:</p>
  
  <blockquote>
    <p>[Sat Nov 24 20:04:52 2012] [error] [client 127.0.0.1] PHP Notice: 
    Uninitialized string offset: 0 in
    /var/www/libs/plugins/modifier.sortby.php(33) : runtime-created
    function on line 1</p>
  </blockquote>