Javascript sort specific table columns, via button
<p><strong>what I'm trying to do:</strong></p>

<ul>
<li>JS script in use: sorttable from
<a href="http://www.kryogenix.org/code/browser/sorttable/" rel="nofollow">http://www.kryogenix.org/code/browser/sorttable/</a></li>
</ul>

<p>I'm trying to create the direct code for sorting a table by a certain column. The intent is creating a multiple event onclick button that includes a sorttable call. </p>

<p><strong>Background:</strong></p>

<p>I'm currently working on a project that requires a sortable table. We're using sorttable which is doing the job nicely. The rows are issue tickets from our ticketing system, background-color coded (green, yellow, red) to indicate which tickets have been handled in a timely manner (green) through which have gone out of range (red). We have several onclick buttons that filters (hide/show) the rows based on color. </p>

<p>Recently I was asked that those filter buttons not only hide/show the appropriate rows, but that they also sort the results based on a certain column...Yes, I know, they could just click the column to sort it manually but they want the buttons to do that. </p>

<p><strong>Current code:</strong></p>

<pre><code>&lt;input type="button" value="Show All Tickets" onclick="showRows('green');showRows('yellow');showRows('red');"&gt;
&lt;input type="button" value="Show Yellow &amp; Red" onclick="hideRows('green');showRows('yellow');showRows('red');"&gt;
&lt;input type="button" value="Show Yellow Only" onclick="hideRows('green');showRows('yellow');hideRows('red');"&gt;
&lt;input type="button" value="Show Red Only" onclick="hideRows('green');hideRows('yellow');showRows('red');"&gt;
</code></pre>

<p><strong>Resulting code:</strong></p>

<p>Ideally a function call like 'sorttable' with (#,#) being the column# and whether to sort asc/desc.</p>

<pre><code>&lt;input type="button" value="Show All Tickets" onclick="showRows('green');showRows('yellow');showRows('red');sorttable(2,0);"&gt;
&lt;input type="button" value="Show Yellow &amp; Red" onclick="hideRows('green');showRows('yellow');showRows('red');sorttable(4,1);"&gt;
&lt;input type="button" value="Show Yellow Only" onclick="hideRows('green');showRows('yellow');hideRows('red');sorttable(0,0);"&gt;
&lt;input type="button" value="Show Red Only" onclick="hideRows('green');hideRows('yellow');showRows('red');sorttable(2,1);"&gt;
</code></pre>

<p>Is what I'm looking for doable with this script? I found a JQuery script (Tablesorter) that looks to do the job, but I prefer to NOT make changes to the core components and find a JS solution instead.</p>

<p>Thank you!</p>
