I am using jQuery Datatables on one of my tables for easy filtering, searching, and sorting. However, I would like to order my rows on page load based on the last name. The tricky part is, is that the cell that contains the last name, contains the full name.
HTML
<table id="Test-Table" class="table table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>20</td>
</tr>
<tr>
<td>Jane Doe</td>
<td>29</td>
</tr>
<tr>
<td>Greg Maddux</td>
<td>51</td>
</tr>
<tr>
<td>David Goggins</td>
<td>45</td>
</tr>
<tr>
<td>Walter Bond</td>
<td>60</td>
</tr>
</tbody>
</table>
jQuery
$(document).ready(function(){
$("#Test-Table").DataTable();
});
Here is my Fiddle.
I assume I would split the name somehow and then order by the last name, and then the first name if two people were to have the same last name?
Any help on how to accomplish this would be greatly appreciated.