orderBy filter has odd results when nulls are compared to Date objects #11312
Description
Granted, "odd results" are better than bombing completely, which I think is what used to happen in some cases for orderBy. When you have nulls in the property that is being compared in an orderBy filter and that property is generally a Date (or anything else where .valueOf evaluates to a number but typeof === "object"), the results are effectively unpredictable.
In compare, typeof null evaluates to "object", and typeof also evaluates to "object". Thus, we fall into the t1 === t2 && t1 === "object" block, which calls objectToString() on both values. The null ends up getting converted into a string ("null"), and then the Date ends up getting converted into a number by .valueOf. Back up in compare(), the code goes into the next t1 === t2 block. The values are not equal, so it tries the less than check. "null" < any number always evaluates to false, and so the sort order ends up inconsistent (since the null can be either v1 or v2 depending on the call to compare()). The nulls don't go to either the top or the bottom of the list consistently, regardless of sorting "regular" or "reverse".
I can throw together a plunkr later (too late tonight), but I suspect this is at least enough to get someone thinking. :)
Angular version 1.3.13