imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
59 stars 20 forks source link

sortedData and filterData #3

Closed ans-4175 closed 7 years ago

ans-4175 commented 7 years ago

Hey, maybe you could change your sorting implementation using lodash or something lightweight like this

if (this.state.sortedProp.isAscending) {
    descendingMultiplier = [1, -1];
} else {
    descendingMultiplier = [-1, 1];
}

sortedData.sort((a, b) => {
    if (a[sortedProp] < b[sortedProp]) {
      return descendingMultiplier[0];
    } else if (a[sortedProp] > b[sortedProp]) {
      return descendingMultiplier[1];
    } else {
      return 0;
    }
}