AllenFang / AllenFang/react-bootstrap-table

Sorting of undefined properties causes undefined result

Open
#1,017 3 comments 0 reactions 0 assignees View on GitHub
enhancement in progress
Dominant language
JavaScript
Stars
2.2k
Forks
761
PR merge metrics
No merged PRs in 30d

Description

In my data, some records are missing a property that I display in a sortable column.

I assume this results in the value used for comparisons being `undefined` which messes up sorting. Strangely enough, Chrome still sorts as unexpected but Firefox messes up.

I already did some browsing and found that `null` is handled specially but not `undefined`
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/store/TableDataStore.js#L565

I guess its because the comparison operators `<` and `>` cause unexpected results in combination with `undefined` operands, e.g.:
```javascript
"a" < undefined
false

undefined < "a"
false
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.