I need to sort an array of strings in the format "05/17/2005 01:33 AM" by date
using javascript. For that I need a custom sort function. What I have so far is:
function sortTable()
{
sortfn = mysort;
var newRows = new Array();
for (j=1;j<newIndex.rows.length;j++) newRows[j-1] = newIndex.rows[j];
newRows.sort(mysort);
}
function mysort(a,b)
{
aa = a.cells[2].firstChild.innerHTML;
bb = b.cells[2].firstChild.innerHTML;
dt1 =
aa.substr(6,4)+aa.substr(0,2)+aa.substr(3,2)+aa.substr(11,2)+aa.substr(14,2);
dt2 =
bb.substr(6,4)+bb.substr(0,2)+bb.substr(3,2)+bb.substr(11,2)+bb.substr(14,2);
if (dt1==dt2) return 0;
if (dt1>dt2) return -1;
return 1;
};
How do I get proper AM/PM parsing into this?
Jochem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:157844
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54