Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

orderBy: incorrect sorting of string arrays with null values #15293

Closed
@arw-travela

Description

@arw-travela

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions