// Table data sorting starts....
function sortData() {
// Read table body node.
var tableData = document.getElementById('data_table').getElementsByTagName('tbody').item(0);
// Read table row nodes.
var rowData = tableData.getElementsByTagName('tr');
for(var i = 0; i < rowData.length - 1; i++) {
for(var j = 0; j < rowData.length - (i + 1); j++) {
//Swap row nodes if short condition matches
if(parseInt(rowData.item(j).getElementsByTagName('td').item(0).innerHTML) > parseInt(rowData.item(j+1).getElementsByTagName('td').item(0).innerHTML)) {
tableData.insertBefore(rowData.item(j+1),rowData.item(j));
}
}
}
}
// Table data sorting ends....
<table id="data_table" width="200" border="1">
<tbody>
<tr>
<td width="100">01</td>
<td>aaa</td>
</tr>
<tr>
<td>04</td>
<td>ddd</td>
</tr>
<tr>
<td>05</td>
<td>eee</td>
</tr>
<tr>
<td>03</td>
<td>ccc</td>
</tr>
<tr>
<td>02</td>
<td>bbb</td>
</tr>
<tr>
<td>06</td>
<td>fff</td>
</tr>
</tbody>
</table>
<table id="data_table" width="200" border="1">
<tbody>
<tr>
<td width="100">01</td>
<td>aaa</td>
</tr>
<tr>
<td>02</td>
<td>bbb</td>
</tr>
<tr>
<td>03</td>
<td>ccc</td>
</tr>
<tr>
<td>04</td>
<td>ddd</td>
</tr>
<tr>
<td>05</td>
<td>eee</td>
</tr>
<tr>
<td>06</td>
<td>fff</td>
</tr>
</tbody>
</table>