user1741396
user1741396

Reputation: 33

Sorting time column with jquery tablesorter

I am using jquery tablesorter to add sorting to a table. I'm having issues sorting a column with only hh:mm:ss in it. The SQL query producing this data is basically a now() - datetime field then in SQL I format it to hh:mm:ss. When sorting the column tablesorter does not appear to recognize the time format and as a result does not sort it correctly. Is there a way to correct this so that the times are sorted correctly?

Sorting Example: 53:47:57 53:33:34 530:54:38 52:12:14 52:07:58 526:21:35 51:53:41 51:53:26 51:41:34

Upvotes: 1

Views: 2783

Answers (2)

Mottie
Mottie

Reputation: 86443

Tablesorter has a built-in time parser (missing docs), try this:

$("table").tablesorter({
    headers: {
        0: { sorter: 'time'}
    }
});

Upvotes: 4

PSR
PSR

Reputation: 40338

$("#tableId").tablesorter({
    headers: { column Number: { sorter: 'shortDate'} }
});

Upvotes: 0

Related Questions