I don't know how sort works in Javascript (what the requirements for the cmp function are) but what happens when the dates are equal? Could the sort function get confused? I mean if a == b then cmp(a,b) returns -1 and cmp(b,a) also.