//when using thymeleaf
$(document).ready(function() {
$('#example').DataTable( {
"order": [
[0, "desc"]
]
} );
} );
Datatable.DefaultView.Sort = "Preferance ASC";
//Sorting the Table
DataView dv = dt.DefaultView;
dv.Sort = "ParamValue asc";
DataTable sortedtable1 = dv.ToTable();