I have a little cheater method that I use for sorting by property in JavaScript. I'm feeling magnanimous, so you can have it today, in all its scary-long glory.
propSort = function(array,prop, desc) {
array.sort(function(a, b) {
if (a[prop] < b[prop])
return desc ? 1 : -1;
if (a[prop] > b[prop])
return desc ? -1 : 1;
return 0;
});
}
This is the basic JavaScript array sort custom filter pattern. It uses basic JS comparison to make determinations, which is always shocks me in terms of accuracy, coming from a strongly-typed language world.
...
success: function (data) {
var leadCourseActivities = '<table id="tblLeadCourseRecentActivities" class="table table-striped table-bordered table-hover table-responsive"><thead><table><tbody><tr class="primary"><th>Activity Type</th><th>Subject</th><th>Description</th><th>Due On</th></tr></tbody></table></thead><tbody>';
var countRA = 1;
debugger;
propSort(data,'DueDate',true);
...
</tbody></table>
The array.sort function works on the array itself, it doesn't spin off a copy. It's basically like working with a reference in a C-derivative language.