I'm trying to sort table row using jquery which has function like this:
var items = $('#dp_content_table > tbody > tr').sort(function(a, b) {
var vA = $(a).attr('id');
var vB = $(b).attr('id');
var arrA = vA.split('_');
var arrB = vB.split('_');
return (arrA[1] < arrB[1]) ? -1 : (arrA[1] > arrB[1]) ? 1 : (arrA[1] == arrB[1] && arrA[5] < arrB[5]) ? -1 : (arrA[1] == arrB[1] && arrA[5] > arrB[5]) ? 1 : 0;
});
$('#dp_content_table > tbody > tr').append(items);
Basically, I'm using ID as attribute for sorting. The attribute contain day & time. attr[1] is day, and attr[5] is time. If day in row A is less than B, then no need for comparing the time, and return result, on the other hand, if days are same, then compare the second attribute which is the time, and so on.
But, so far I have no luck in sorting them. My table seems doesn't take effect at all.
Thanks before.