Sorting by total hours and minutes
Sorting by total hours and minutes
I'm using datables in my app to display a report to the user with two columns. Column1 contains a name, and Column2 contains a totaled time value in the format, X hours Y minutes.
For example here is a typical result sorted in desc:
Column1 Column2
Shawn 73 hours 3 minutes
Bob 4 minutes
Steve 24 minutes
Charles 1 hour 53 minutes
When attempting to sort Column2 (asc/desc) it appears to be reading the first number and using that as the basis for sorting, but I need the entire value to be sorted, so that it displays it sorted correctly.
What would be the best way to achieve this? I see that there is a date/time plugin for datatables, but since I'm using the cumulative value of time, I'm not sure this would work.
Thanks for your time and assistance.
For example here is a typical result sorted in desc:
Column1 Column2
Shawn 73 hours 3 minutes
Bob 4 minutes
Steve 24 minutes
Charles 1 hour 53 minutes
When attempting to sort Column2 (asc/desc) it appears to be reading the first number and using that as the basis for sorting, but I need the entire value to be sorted, so that it displays it sorted correctly.
What would be the best way to achieve this? I see that there is a date/time plugin for datatables, but since I'm using the cumulative value of time, I'm not sure this would work.
Thanks for your time and assistance.
This discussion has been closed.
Replies
1. Use orthogonal data: http://datatables.net/blog/Orthogonal_data
2. Use a sorting plug-in which is modified to read data from your time format.
Allan