var sorted = results.sort(function (a, b) {
var nameA = "";
var nameB = "";
var str1 = a.date.toLowerCase() + " " + a.time;
var str2 = b.date.toLowerCase() + " " + b.time;
if (a.date.toLowerCase() != "" && a.time!= "")
nameA = Date.parse(new Date(str1))
if (b.date.toLowerCase() != "" && b.time!= "")
nameB = Date.parse(new Date(str2))
return nameA === nameB ? 0 : nameA < nameB ? -1 : 1;
});
- Can anyone improve the code, if there any faults in the way i am
sorting. Is there any better approach?
- How can i implement
http://underscorejs.org/#sortBy
for the above
sorting.