I have a data table in which I am adding values dynamically . There is a column having button as stars . I want to sort the table so that entry with minimum stars sort button will come first.
I have tried doing it using the data tables sort provided in datatables.
s=s+'<thead>'+
'<tr role=\"row\">'+
'<th>Sr.No</th>'+
'<th width="128">Company Name</th>'+
'<th>A</th>'+
'<th>B</th>'+
'<th>C</th>'+
'<th>D</th>'+
'</tr>'+
'</thead>'+
'<tbody>';
for(i=0;i<jsonData.array_list.length;i++)
{
j[i]=i;
s=s+'<tr>'+
'<td>'+(i+1)+'</td>'+
'<td id="A-{i}" width="64">'+jsonData.array_list[i]["A"]+'</td>'+
/*'<td>'+jsonData.array_list[i]["B"]+'</td>'+
'<td>'+jsonData.array_list[i]["year_founded"]+'</td>'+*/
'<td>'+jsonData.array_list[i]["C"]+'</td>'+
'<td nowrap>';
if(jsonData.array_list[i].details_content_complete==='1')
{
s=s+'<button class="btn btn-sm btn-white btn-social-icon"><i class="fa fa-star" style="color:#FF9900;font-size:20px;border:1px solid #dadada;padding:1px;"></i></button>';
}
else{
s=s+'<button class="btn btn-sm btn-white btn-social-icon"><i class="fa fa-star-o" style="color:#DADADA;font-size:20px;border:1px solid #dadada;padding:1px;"></i></button>';
}
s=s.replace(/{i}/g, i+1);
}
s=s+'</tbody>';
$("#userListTable").html(s);
var table=$('#userListTable').DataTable( {
data: arr,
columns: [
{ title: "D"}
]
} );