title: How to sort a html table using javascript based on column index
body: <p>I'm using a table with the structure </p>
  
  <pre><code>&lt;table cellspacing="0" cellpadding="3" rules="cols" border="1" id="ctl00_Content_GrdCustomer" style="color:Black;border-color:#999999;width:640px;border-collapse:collapse;"&gt;
      &lt;tr style="color:White;background-color:Black;font-weight:bold;"&gt;
          &lt;th scope="col"&gt;Something&lt;/th&gt;
          &lt;th scope="col"&gt;Client Name&lt;/th&gt;
          &lt;th scope="col"&gt;Address&lt;/th&gt;
          &lt;th scope="col"&gt;Place&lt;/th&gt;
          &lt;th scope="col"&gt;City&lt;/th&gt;
          &lt;th scope="col"&gt;Country&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr class="home-history-grid-row customerData"&gt;
          &lt;td align="center" style="width:50px;"&gt;&lt;!--Checkbox Goes Here--&gt;&lt;/td&gt;
          &lt;td align="center"&gt;Raju Varghese&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;Country4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="home-history-grid-row customerData"&gt;
          &lt;td align="center" style="width:50px;"&gt;&lt;!--Checkbox Goes Here--&gt;&lt;/td&gt;
          &lt;td align="center"&gt;Joseph K. J&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;Country4&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I need to sort the table based on the 'th' with header 'Client Name'. Gone through so many links and all are sorting based on header clicks and i dont know javascript much. Kindly help</p>