Sorting on two date fields and a numeric field example:
var generic_date = new Date(2070, 1, 1);
checkDate = function(date) {
return Date.parse(date) ? new Date(date): generic_date;
}
function sortData() {
data.sort(function(a,b){
var deltaEnd = checkDate(b.end) - checkDate(a.end);
if(deltaEnd) return deltaEnd;
var deltaRank = a.rank - b.rank;
if (deltaRank) return deltaRank;
var deltaStart = checkDate(b.start) - checkDate(a.start);
if(deltaStart) return deltaStart;
return 0;
});
}