orderBy: incorrect sorting of string arrays with null values #15293
Description
Bug, seen in angular 1.5.7, chrome 53.0.2785.143 (64-bit) (Windows) and IE11, Also Chrome on OSX.
Using $filter('orderBy')(...) with a collection that contains strings, but some entries are null, results in the entries with null being sorted as if their entries contained the string null
instead.
Expected behavior is that entries with null in the sort column would be treated as blank.
Internally replacing a nonexistent value with the string null
for the purposes of comparison results in an unexpected sort order.
We have confirmed that in angular 1.2.27 arrays with null entries behaves with the expected behavior, so this is an undocumented regression.
The code in https://github.com/angular/angular.js/blob/master/src/ng/filter/orderBy.js#L654-L656 that sets value = 'null'
results in the unexpected behavior. The immediate fix isn't obvious, since that change was made to address a specific issue with unspecified predicates in 48e1f56.