Skip to content

sortService.sortData assumes that users want to sort nulls to bottom  #545

@tensory

Description

@tensory

My data can contain null values. While porting from ng-grid 2.0.1 to 2.0.7, I noticed that my custom sortFn function that sorts nulls to the top of an ascending list no longer works. It did that by assigning NaNs to 0.

In ng-grid-2.0.7.debug.js I notice this comment on line 470:
// we want to force nulls and such to the bottom when we sort... which effectively is "greater than"

For my purposes that's not true. Nulls should be sorted as though they were 0s. I am getting around this behavior by replacing the logic starting on line 469 with calling sortFn and allowing sortFn's definition to do the substitution:

tem = sortFn(propA, propB);

But, I would like to see this assumption revised, since I couldn't come up with a sortFn to pass in that would overcome the incorrect assumption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions