JQuery sorting in table
<p>I have a table, that looks like this:</p>

<pre><code>&lt;table class="sortabletable"&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style="width: 80px;" class="sort-numeric"&gt;Nummer&lt;/th&gt;
      &lt;th style="width: 160px;" class="sort-alphabetic"&gt;Navn&lt;/th&gt;
      ...
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody id="jLineContainer"&gt;
    &lt;tr class="journal_line"&gt;
      &lt;td&gt;&lt;input type="hidden" name="lineno"/&gt;&lt;input type="text" value="2088"/&gt;&lt;/td&gt;
      &lt;td &gt;&lt;input type="text" value="Anonymous"/&gt;&lt;/td&gt;
      ...
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>

<p>I have then created a JQuery, that looks like this</p>

<pre><code>$(document).ready(function () {

  var getCellText = function ($cell) {
    $cell.find("input:not([name^=lineno])").each(function () {
      return this.value;
    });
  }

  $('table.sortabletable').each(function () {
    var $table = $(this);

    $('th', $table).each(function (column) {
      var findSortKey;

      ...

      if (findSortKey) {
        $(this).addClass('clickable').click(function () {

          var rows = $table.find('tbody &gt; tr').get();

          $.each(rows, function (index, row) {
            row.sortKey = findSortKey($(row).children('td').eq(column));
          });

          rows.sort(function (a, b) {
            if (a.sortKey &lt; b.sortKey) return -1;
            if (a.sortKey &gt; b.sortKey) return 1;
            return 0;
          });

          $.each(rows, function (index, row) {
            $table.children('tbody').append(row);
            row.sortKey = null;
          });

          $table.find('td').removeClass('sorted').filter(':nth-child(' + (column + 1) + ')').addClass('sorted');
        });
      }
    });
  });
});
</code></pre>

<p>This JQuery-function is found on <a href="http://www.packtpub.com/article/jquery-table-manipulation-part1" rel="nofollow">http://www.packtpub.com/article/jquery-table-manipulation-part1</a></p>

<p>The problem is that I cannot set the function to start, when I click in the th</p>
