Skip to content

bug(table-data-source): Sorting of a string column/property breaks if one record contains a number only #20140

Closed
@stnor

Description

@stnor

Reproduction

[edit, thanks @jelbourn]
https://stackblitz.com/edit/angular-xpwhup?file=src/app/table-sorting-example.ts

Expected Behavior

The sorting of strings should work as one expects when values are strings.

Actual Behavior

The sortingDataAccessor won't sort a string column correctly if one or more records contain a number only eg '1'.

Ex: ['One' ,'2', 'Three']

Suggested change

Use typeof value === 'number' instead of _isNumberValue perhaps, or something more elaborate?

Environment

  • Angular: 10
  • CDK/Material:10

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/tablegood first issueThis issue is a good place to start for first time contributors to the projecthelp wantedThe team would appreciate a PR from the community to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions