Datatable custom sort function on a given column <p>I am using jquery datatables and I need to sort data by the first column which contains checkboxes by displaying checked boxes first </p> <pre><code>oTable = $('#userTable', context).dataTable( { "sAjaxSource":'/ajax/getdata/', "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "dataType": 'json', "type": "POST", "url": sSource, "data": params, "success" : function(data) { fnCallback(data); fnSortBySelected(); } }); } }); var fnSortBySelected = function() { var oSettings = oTable.fnSettings(); var i = 0; $('td:first-child input[type=checkbox]',oTable).sort(function(a, b) { if(a.checked) oTable.fnUpdate( oSettings.aoData[i]._aData, i, 0); else oTable.fnUpdate( oSettings.aoData[i+1]._aData, i, 0); i++; }); } </code></pre> <hr> <p>thanks for your time , this is what i tried so far :</p> <pre><code> oTable = $('#userTable', context).dataTable({ "sAjaxSource":'/ajax/getdata/', "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "dataType": 'json', "type": "POST", "url": sSource, "data": params, "success" : function(data){ fnCallback(data); fnSortBySelected(); } } ); } }); var fnSortBySelected = function() { var oSettings = oTable.fnSettings(); var i = 0; $('td:first-child input[type=checkbox]',oTable).sort(function(a, b){ if(a.checked) oTable.fnUpdate( oSettings.aoData[i]._aData, i, 0); else oTable.fnUpdate( oSettings.aoData[i+1]._aData, i, 0); i++; } ); } </code></pre>