title: How do I do table sorting using CodeIgniter?
body: <p>I've been developing a site over the past few weeks using CodeIgniter as the framework. I've been thinking of the best way to accomplish something, which in a lot of other frameworks in other languages is relatively simple: sortable tables. CodeIgniter switches off query strings by default, because your URLs contain method parameters. So a URL might look like:</p>
  <pre><code>/controller/method/param1/param2
  </code></pre>
  <p>You might think that you could just add in <code>sortBy</code> and <code>sortOrder</code> as two additional parameters to the controller method. I don't particularly want to do that, mainly because I want to have a re-usable controller. When you use query string parameters, PHP can easily tell you whether there is a parameter called <code>sortBy</code>. However, when you're using URL based parameters, it will vary with each controller.</p>
  <p>I was wondering what my options were. As far as I can see they are something like:</p>
  <ul>
  <li>Pass in my <code>sortBy</code> and <code>sortOrder</code> parameters, just suck it up, and develop some less-than-reusable component for it.</li>
  <li>Have an additional controller, which will store the <code>sortBy</code> and <code>sortOrder</code> in the session (although it would have to know where you came from, and send you back to the original page).</li>
  <li>Have some kind of AJAX function, which would call the controller above; then reload the page.</li>
  <li>Hack CodeIgniter to turn query strings back on. Actually, if this is the only option, any links to how to do this would be appreciated.</li>
  </ul>
  <p>I just can't quite believe such a simple task would present such a problem! Am I missing something? Does anyone have any recommendations?</p>
  <p>While I love jQuery, and I'm already using it on the site, so TableSorter is a good option. However, I would like to do server-side sorting as there are some pages with potentially large numbers of results, including pagination.</p>