Sorting by date with extra text in field

Sorting by date with extra text in field

mlopezmlopez Posts: 1Questions: 0Answers: 0
edited June 2013 in General
Hi im trying to sort a field by date (UK) and have it working using the following code:

[code]/* Datatables */
$("#tasks").dataTable({
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"aoColumns": [
{"bSortable": false},
null,
null,
null,
{"sType": "date-uk"}
]
});
$.extend($.fn.dataTableExt.oStdClasses, {
"sSortable": "header",
"sWrapper": "dataTables_wrapper form-inline"
});
$.extend($.fn.dataTableExt.oSort, {
"date-uk-pre": function (a) {
var ukDatea = a.split("/");
return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
},
"date-uk-asc": function (a, b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"date-uk-desc": function (a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
/* End */[/code]

What i want to do is show the date and then have some text after it e.g.

22/08/2013 (Due in 5 days)

Obviosuly it breaks sorting, is there a way to ignore the stuff in the brackets and sort by date correctly?
This discussion has been closed.